(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestNodeIDsMarshalJSON(t *testing.T) { |
| 27 | testCases := map[string]struct { |
| 28 | ids NodeIDs |
| 29 | exp string |
| 30 | }{ |
| 31 | "Empty list": {NodeIDs([]int{}), `""`}, |
| 32 | "One": {NodeIDs([]int{123}), `"123"`}, |
| 33 | "Many": {NodeIDs([]int{1, 2, 3}), `"1,2,3"`}, |
| 34 | } |
| 35 | for name, tc := range testCases { |
| 36 | t.Run(name, func(t *testing.T) { |
| 37 | got, err := tc.ids.MarshalJSON() |
| 38 | if err != nil { |
| 39 | t.Fatalf("expected nil; got %v", err) |
| 40 | } |
| 41 | if string(got) != tc.exp { |
| 42 | t.Fatalf("expected %v; got %v", tc.exp, string(got)) |
| 43 | } |
| 44 | }) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestNodeIDsUnmarshalJSON(t *testing.T) { |
| 49 | cmpNodeIDs := func(a, b NodeIDs) bool { |
nothing calls this directly
no test coverage detected