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

Function TestNodeIDsUnmarshalJSON

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

Source from the content-addressed store, hash-verified

46}
47
48func TestNodeIDsUnmarshalJSON(t *testing.T) {
49 cmpNodeIDs := func(a, b NodeIDs) bool {
50 if len(a) != len(b) {
51 return false
52 }
53 for i, id := range a {
54 if id != b[i] {
55 return false
56 }
57 }
58 return true
59 }
60
61 testCases := map[string]struct {
62 json string
63 exp NodeIDs
64 }{
65 "Empty list": {`""`, NodeIDs([]int{})},
66 "One": {`"123"`, NodeIDs([]int{123})},
67 "Many": {`"1,2,3"`, NodeIDs([]int{1, 2, 3})},
68 }
69 for name, tc := range testCases {
70 t.Run(name, func(t *testing.T) {
71 var got NodeIDs
72 if err := json.Unmarshal([]byte(tc.json), &got); err != nil {
73 t.Fatalf("expected nil; got %v", err)
74 }
75 if !cmpNodeIDs(got, tc.exp) {
76 t.Fatalf("expected %v; got %v", tc.exp, got)
77 }
78 })
79 }
80}
81
82func TestLatency(t *testing.T) {
83 ctx := context.Background()

Callers

nothing calls this directly

Calls 1

NodeIDsTypeAlias · 0.85

Tested by

no test coverage detected