MCPcopy Index your code
hub / github.com/coder/coder / TestSanitizeLogOutput

Function TestSanitizeLogOutput

codersdk/agentsdk/logs_test.go:20–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestSanitizeLogOutput(t *testing.T) {
21 t.Parallel()
22
23 tests := []struct {
24 name string
25 in string
26 want string
27 }{
28 {
29 name: "valid",
30 in: "hello world",
31 want: "hello world",
32 },
33 {
34 name: "invalid utf8",
35 in: "test log\xc3\x28",
36 want: "test log❌(",
37 },
38 {
39 name: "nul byte",
40 in: "before\x00after",
41 want: "before❌after",
42 },
43 {
44 name: "invalid utf8 and nul byte",
45 in: "before\x00middle\xc3\x28after",
46 want: "before❌middle❌(after",
47 },
48 {
49 name: "nul byte at edges",
50 in: "\x00middle\x00",
51 want: "❌middle❌",
52 },
53 {
54 name: "invalid utf8 at edges",
55 in: "\xc3middle\xc3",
56 want: "❌middle❌",
57 },
58 }
59
60 for _, tt := range tests {
61 t.Run(tt.name, func(t *testing.T) {
62 t.Parallel()
63 require.Equal(t, tt.want, agentsdk.SanitizeLogOutput(tt.in))
64 })
65 }
66}
67
68func TestStartupLogsWriter_Write(t *testing.T) {
69 t.Parallel()

Callers

nothing calls this directly

Calls 3

SanitizeLogOutputFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected