MCPcopy Index your code
hub / github.com/coder/envbox / TestJSONLog

Function TestJSONLog

buildlog/json_test.go:15–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestJSONLog(t *testing.T) {
16 t.Parallel()
17
18 type testcase struct {
19 name string
20 expectedLog buildlog.JSONLog
21 logFn func(l buildlog.Logger)
22 }
23
24 cases := []testcase{
25 {
26 name: "Info",
27 expectedLog: buildlog.JSONLog{
28 Output: "foo",
29 Type: buildlog.JSONLogTypeInfo,
30 },
31 logFn: func(l buildlog.Logger) {
32 l.Info("foo")
33 },
34 },
35 {
36 name: "Infof",
37 expectedLog: buildlog.JSONLog{
38 Output: "foo: bar",
39 Type: buildlog.JSONLogTypeInfo,
40 },
41 logFn: func(l buildlog.Logger) {
42 l.Infof("foo: %s", "bar")
43 },
44 },
45 {
46 name: "Error",
47 expectedLog: buildlog.JSONLog{
48 Output: "some error",
49 Type: buildlog.JSONLogTypeError,
50 },
51 logFn: func(l buildlog.Logger) {
52 l.Error("some error")
53 },
54 },
55 {
56 name: "Errorf",
57 expectedLog: buildlog.JSONLog{
58 Output: "some error: my error",
59 Type: buildlog.JSONLogTypeError,
60 },
61 logFn: func(l buildlog.Logger) {
62 l.Errorf("some error: %v", xerrors.New("my error"))
63 },
64 },
65 {
66 name: "Close",
67 expectedLog: buildlog.JSONLog{
68 Output: "",
69 Type: buildlog.JSONLogTypeDone,
70 },
71 logFn: func(l buildlog.Logger) {
72 l.Close()

Callers

nothing calls this directly

Calls 6

InfoMethod · 0.65
InfofMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected