mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
Adding telemetry for catching issue #19172 # Docs changes In another PR: https://github.com/fleetdm/fleet/pull/23423/files # Demo <div> <a href="https://www.loom.com/share/233625875eec46508c26ae315cd52d19"> <p>[Demo] Add telemetry for vital fleetd errors - Issue #23413 - Watch Video</p> </a> <a href="https://www.loom.com/share/233625875eec46508c26ae315cd52d19"> <img style="max-width:300px;" src="https://cdn.loom.com/sessions/thumbnails/233625875eec46508c26ae315cd52d19-45ca0ec1b7b5e9e7-full-play.gif"> </a> </div> # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [x] Added/updated tests - [x] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [x] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [x] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [x] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package execuser
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestTransientWriter(t *testing.T) {
|
|
t.Parallel()
|
|
tests := []struct {
|
|
name string
|
|
p [][]byte
|
|
want string
|
|
}{
|
|
{
|
|
name: "empty",
|
|
p: nil,
|
|
want: "",
|
|
},
|
|
{
|
|
name: "small",
|
|
p: [][]byte{[]byte("abc")},
|
|
want: "abc",
|
|
},
|
|
{
|
|
name: "small_2",
|
|
p: [][]byte{[]byte("abc"), []byte("def")},
|
|
want: "abcdef",
|
|
},
|
|
{
|
|
name: "large",
|
|
p: [][]byte{[]byte(strings.Repeat("a", bufSize))},
|
|
want: strings.Repeat("a", bufSize),
|
|
},
|
|
{
|
|
name: "large_2",
|
|
p: [][]byte{[]byte(strings.Repeat("a", bufSize-1)), []byte(strings.Repeat("b", bufSize-1))},
|
|
want: "a" + strings.Repeat("b", bufSize-1),
|
|
},
|
|
{
|
|
name: "large_3",
|
|
p: [][]byte{[]byte(strings.Repeat("a", bufSize) + "b")},
|
|
want: strings.Repeat("a", bufSize-1) + "b",
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
tw := &TransientWriter{}
|
|
for _, p := range tt.p {
|
|
n, err := tw.Write(p)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, len(p), n)
|
|
}
|
|
assert.Equal(t, tt.want, tw.String())
|
|
})
|
|
}
|
|
}
|