MCPcopy Index your code
hub / github.com/micro/go-micro / TestStructArray

Function TestStructArray

config/reader/json/values_test.go:54–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func TestStructArray(t *testing.T) {
55 type T struct {
56 Foo string
57 }
58
59 emptyTSlice := []T{}
60
61 testData := []struct {
62 csdata []byte
63 accepter []T
64 value []T
65 }{
66 {
67 []byte(`[{"foo": "bar"}]`),
68 emptyTSlice,
69 []T{{Foo: "bar"}},
70 },
71 }
72
73 for idx, test := range testData {
74 values, err := newValues(&source.ChangeSet{
75 Data: test.csdata,
76 })
77 if err != nil {
78 t.Fatal(err)
79 }
80
81 v, err := values.Get()
82 if err != nil {
83 t.Fatal(err)
84 }
85 err = v.Scan(&test.accepter)
86 if err != nil {
87 t.Fatal(err)
88 }
89 if !reflect.DeepEqual(test.accepter, test.value) {
90 t.Fatalf("No.%d Expected %v got %v", idx, test.value, test.accepter)
91 }
92 }
93}

Callers

nothing calls this directly

Calls 5

newValuesFunction · 0.85
FatalMethod · 0.80
GetMethod · 0.65
ScanMethod · 0.65
FatalfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…