github.com/koko1123/flow-go-1@v0.29.6/engine/access/ping/node_info_test.go (about) 1 package ping 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "testing" 7 8 "github.com/koko1123/flow-go-1/model/flow" 9 "github.com/koko1123/flow-go-1/utils/unittest" 10 11 "github.com/stretchr/testify/require" 12 "github.com/stretchr/testify/suite" 13 ) 14 15 type Suite struct { 16 suite.Suite 17 } 18 19 func TestHandler(t *testing.T) { 20 suite.Run(t, new(Suite)) 21 } 22 23 func TestUnmarshalNodeInfoFromJSONData(t *testing.T) { 24 totalNodes := 10 25 ids := unittest.IdentifierListFixture(totalNodes) 26 testJson := make(map[flow.Identifier]string, totalNodes) 27 for i, id := range ids { 28 testJson[id] = fmt.Sprintf("Operator%d", i+1) 29 } 30 jsonAsBytes, err := json.Marshal(testJson) 31 require.NoError(t, err) 32 content, err := unmarshalNodeInfoFromJSONData(jsonAsBytes) 33 require.NoError(t, err) 34 require.Len(t, content, totalNodes) 35 for k, v := range testJson { 36 require.Contains(t, content, k) 37 require.Equal(t, content[k], v) 38 } 39 }