code.vegaprotocol.io/vega@v0.79.0/protos/embed_test.go (about) 1 package protos_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 "github.com/stretchr/testify/require" 8 9 "code.vegaprotocol.io/vega/protos" 10 ) 11 12 func Test_CoreBindings(t *testing.T) { 13 t.Run("CoreBindings should return the core http bindings", func(t *testing.T) { 14 bindings, err := protos.CoreBindings() 15 require.NoError(t, err) 16 17 assert.Len(t, bindings.HTTP.Rules, 21) 18 19 postCount := 0 20 getCount := 0 21 22 for _, rule := range bindings.HTTP.Rules { 23 if rule.Post == nil && rule.Get == nil { 24 continue 25 } 26 27 if rule.Post != nil { 28 postCount++ 29 } 30 31 if rule.Get != nil { 32 getCount++ 33 } 34 } 35 36 assert.Equal(t, 4, postCount) 37 assert.Equal(t, 17, getCount) 38 39 assert.True(t, bindings.HasRoute("GET", "/statistics")) 40 assert.True(t, bindings.HasRoute("POST", "/transactions")) 41 }) 42 } 43 44 func Test_DataNodeBindings(t *testing.T) { 45 t.Run("CoreBindings should return the core http bindings", func(t *testing.T) { 46 bindings, err := protos.DataNodeBindings() 47 require.NoError(t, err) 48 wantCount := 121 49 50 assert.Len(t, bindings.HTTP.Rules, wantCount) 51 52 postCount := 0 53 getCount := 0 54 55 for _, rule := range bindings.HTTP.Rules { 56 if rule.Post == nil && rule.Get == nil { 57 continue 58 } 59 60 if rule.Post != nil { 61 postCount++ 62 } 63 64 if rule.Get != nil { 65 getCount++ 66 } 67 } 68 69 assert.Equal(t, 0, postCount) 70 assert.Equal(t, wantCount, getCount) 71 72 assert.True(t, bindings.HasRoute("GET", "/api/v2/oracle/data")) 73 assert.True(t, bindings.HasRoute("GET", "/api/v2/stream/markets/data")) 74 }) 75 }