MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / TestNodeIDsMarshalJSON

Function TestNodeIDsMarshalJSON

perfops/run_test.go:26–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func 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
48func TestNodeIDsUnmarshalJSON(t *testing.T) {
49 cmpNodeIDs := func(a, b NodeIDs) bool {

Callers

nothing calls this directly

Calls 2

NodeIDsTypeAlias · 0.85
MarshalJSONMethod · 0.80

Tested by

no test coverage detected