(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestPluginMarshal(t *testing.T) { |
| 13 | const jsonWithError = `{"Name":"some-plugin","Err":"something went wrong"}` |
| 14 | const jsonNoError = `{"Name":"some-plugin"}` |
| 15 | |
| 16 | tests := []struct { |
| 17 | doc string |
| 18 | error error |
| 19 | expected string |
| 20 | }{ |
| 21 | { |
| 22 | doc: "no error", |
| 23 | expected: jsonNoError, |
| 24 | }, |
| 25 | { |
| 26 | doc: "regular error", |
| 27 | error: errors.New("something went wrong"), |
| 28 | expected: jsonWithError, |
| 29 | }, |
| 30 | { |
| 31 | doc: "custom error", |
| 32 | error: newPluginError("something went wrong"), |
| 33 | expected: jsonWithError, |
| 34 | }, |
| 35 | } |
| 36 | for _, tc := range tests { |
| 37 | t.Run(tc.doc, func(t *testing.T) { |
| 38 | actual, err := json.Marshal(&Plugin{Name: "some-plugin", Err: tc.error}) |
| 39 | assert.NilError(t, err) |
| 40 | assert.Check(t, is.Equal(string(actual), tc.expected)) |
| 41 | }) |
| 42 | } |
| 43 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…