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

Function TestStartupLogsWriter_Write

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

Source from the content-addressed store, hash-verified

66}
67
68func TestStartupLogsWriter_Write(t *testing.T) {
69 t.Parallel()
70
71 canceledCtx, cancel := context.WithCancel(context.Background())
72 cancel()
73
74 tests := []struct {
75 name string
76 ctx context.Context
77 level codersdk.LogLevel
78 source codersdk.WorkspaceAgentLogSource
79 writes []string
80 want []agentsdk.Log
81 wantErr bool
82 closeFirst bool
83 }{
84 {
85 name: "single line",
86 ctx: context.Background(),
87 level: codersdk.LogLevelInfo,
88 writes: []string{"hello world\n"},
89 want: []agentsdk.Log{
90 {
91 Level: codersdk.LogLevelInfo,
92 Output: "hello world",
93 },
94 },
95 },
96 {
97 name: "multiple lines",
98 ctx: context.Background(),
99 level: codersdk.LogLevelInfo,
100 writes: []string{"hello world\n", "goodbye world\n"},
101 want: []agentsdk.Log{
102 {
103 Level: codersdk.LogLevelInfo,
104 Output: "hello world",
105 },
106 {
107 Level: codersdk.LogLevelInfo,
108 Output: "goodbye world",
109 },
110 },
111 },
112 {
113 name: "multiple newlines",
114 ctx: context.Background(),
115 level: codersdk.LogLevelInfo,
116 writes: []string{"\n\n", "hello world\n\n\n", "goodbye world\n"},
117 want: []agentsdk.Log{
118 {
119 Level: codersdk.LogLevelInfo,
120 Output: "",
121 },
122 {
123 Level: codersdk.LogLevelInfo,
124 Output: "",
125 },

Callers

nothing calls this directly

Calls 9

LogsWriterFunction · 0.92
ErrMethod · 0.80
RunMethod · 0.65
NewMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65
DoneMethod · 0.45
ErrorfMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected