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