cic-chain-events/internal/fetch/graphql_test.go

40 lines
764 B
Go
Raw Normal View History

2023-01-05 12:45:09 +01:00
package fetch
import (
"context"
"os"
2023-01-05 12:45:09 +01:00
"testing"
"github.com/stretchr/testify/suite"
)
var (
graphqlEndpoint = os.Getenv("TEST_GRAPHQL_ENDPOINT")
2023-01-05 12:45:09 +01:00
)
type itGraphqlTest struct {
suite.Suite
graphqlFetcher Fetch
}
func TestPipelineSuite(t *testing.T) {
suite.Run(t, new(itGraphqlTest))
}
func (s *itGraphqlTest) SetupSuite() {
s.graphqlFetcher = NewGraphqlFetcher(GraphqlOpts{
GraphqlEndpoint: graphqlEndpoint,
})
}
func (s *itGraphqlTest) Test_E2E_Fetch_Existing_Block() {
resp, err := s.graphqlFetcher.Block(context.Background(), 14974600)
2023-01-05 12:45:09 +01:00
s.NoError(err)
s.Len(resp.Data.Block.Transactions, 3)
}
func (s *itGraphqlTest) Test_E2E_Fetch_Non_Existing_Block() {
_, err := s.graphqlFetcher.Block(context.Background(), 14974600000)
2023-01-05 12:45:09 +01:00
s.Error(err)
}