testenv

package
v0.0.0-...-208f72d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bench

func Bench(b *testing.B, cfg *Config, f func(b *testing.B, xEnv *Environment))

func Run

func Run(t *testing.T, cfg *Config, f func(t *testing.T, xEnv *Environment))

Types

type Config

type Config struct {
	Subgraphs                          SubgraphsConfig
	RouterOptions                      []core.Option
	OverrideGraphQLPath                string
	OverrideAbsinthePath               string
	ModifyRouterConfig                 func(routerConfig *nodev1.RouterConfig)
	ModifyEngineExecutionConfiguration func(engineExecutionConfiguration *config.EngineExecutionConfiguration)
	ModifySecurityConfiguration        func(securityConfiguration *config.SecurityConfiguration)
	ModifySubgraphErrorPropagation     func(subgraphErrorPropagation *config.SubgraphErrorPropagationConfiguration)
	ModifyCDNConfig                    func(cdnConfig *config.CDNConfiguration)
	DisableWebSockets                  bool
	TLSConfig                          *core.TlsConfig
	TraceExporter                      trace.SpanExporter
	MetricReader                       metric.Reader
	PrometheusRegistry                 *prometheus.Registry
}

type Environment

type Environment struct {
	Context context.Context

	Router                *core.Router
	RouterURL             string
	RouterClient          *http.Client
	Servers               []*httptest.Server
	CDN                   *httptest.Server
	NatsServer            *natsserver.Server
	NatsConnectionDefault *nats.Conn
	NatsConnectionMyNats  *nats.Conn
	SubgraphRequestCount  *SubgraphRequestCount
	// contains filtered or unexported fields
}

func (*Environment) AbsintheSubscriptionURL

func (e *Environment) AbsintheSubscriptionURL() string

func (*Environment) AbsintheWebsocketDialWithRetry

func (e *Environment) AbsintheWebsocketDialWithRetry(header http.Header) (*websocket.Conn, *http.Response, error)

func (*Environment) GraphQLRequestURL

func (e *Environment) GraphQLRequestURL() string

func (*Environment) GraphQLServeSentEventsURL

func (e *Environment) GraphQLServeSentEventsURL() string

func (*Environment) GraphQLSubscriptionURL

func (e *Environment) GraphQLSubscriptionURL() string

func (*Environment) GraphQLWebsocketDialWithRetry

func (e *Environment) GraphQLWebsocketDialWithRetry(header http.Header) (*websocket.Conn, *http.Response, error)

func (*Environment) InitAbsintheWebSocketConnection

func (e *Environment) InitAbsintheWebSocketConnection(header http.Header, initialPayload json.RawMessage) *websocket.Conn

func (*Environment) InitGraphQLWebSocketConnection

func (e *Environment) InitGraphQLWebSocketConnection(header http.Header, initialPayload json.RawMessage) *websocket.Conn

func (*Environment) MakeGraphQLRequest

func (e *Environment) MakeGraphQLRequest(request GraphQLRequest) (*TestResponse, error)

func (*Environment) MakeGraphQLRequestOK

func (e *Environment) MakeGraphQLRequestOK(request GraphQLRequest) *TestResponse

func (*Environment) MakeRequest

func (e *Environment) MakeRequest(method, path string, header http.Header, body io.Reader) (*http.Response, error)

func (*Environment) SetExtraURLQueryValues

func (e *Environment) SetExtraURLQueryValues(values url.Values)

func (*Environment) Shutdown

func (e *Environment) Shutdown()

func (*Environment) WaitForConnectionCount

func (e *Environment) WaitForConnectionCount(desiredCount uint64, timeout time.Duration)

func (*Environment) WaitForMessagesSent

func (e *Environment) WaitForMessagesSent(desiredCount uint64, timeout time.Duration)

func (*Environment) WaitForServer

func (e *Environment) WaitForServer(ctx context.Context, url string, timeoutMs int, maxAttempts int)

func (*Environment) WaitForSubscriptionCount

func (e *Environment) WaitForSubscriptionCount(desiredCount uint64, timeout time.Duration)

func (*Environment) WaitForTriggerCount

func (e *Environment) WaitForTriggerCount(desiredCount uint64, timeout time.Duration)

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
}

type GraphQLRequest

type GraphQLRequest struct {
	Query         string          `json:"query"`
	Variables     json.RawMessage `json:"variables,omitempty"`
	Extensions    json.RawMessage `json:"extensions,omitempty"`
	OperationName json.RawMessage `json:"operationName,omitempty"`
	Header        http.Header     `json:"-"`
}

type GraphQLResponse

type GraphQLResponse struct {
	Data   json.RawMessage `json:"data,omitempty"`
	Errors []GraphQLError  `json:"errors,omitempty"`
}

type NatsData

type NatsData struct {
	Connections []*nats.Conn
	Server      *natsserver.Server
}

type Subgraph

type Subgraph struct {
	// contains filtered or unexported fields
}

func (*Subgraph) ServeHTTP

func (s *Subgraph) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SubgraphConfig

type SubgraphConfig struct {
	Middleware   func(http.Handler) http.Handler
	Delay        time.Duration
	CloseOnStart bool
}

type SubgraphRequestCount

type SubgraphRequestCount struct {
	Global       *atomic.Int64
	Employees    *atomic.Int64
	Family       *atomic.Int64
	Hobbies      *atomic.Int64
	Products     *atomic.Int64
	Test1        *atomic.Int64
	Availability *atomic.Int64
	Mood         *atomic.Int64
	Countries    *atomic.Int64
}

type SubgraphsConfig

type SubgraphsConfig struct {
	GlobalMiddleware func(http.Handler) http.Handler
	GlobalDelay      time.Duration
	Employees        SubgraphConfig
	Family           SubgraphConfig
	Hobbies          SubgraphConfig
	Products         SubgraphConfig
	Test1            SubgraphConfig
	Availability     SubgraphConfig
	Mood             SubgraphConfig
	Countries        SubgraphConfig
}

type TestResponse

type TestResponse struct {
	Body     string
	Response *http.Response
	Proto    string
}

type WebSocketMessage

type WebSocketMessage struct {
	ID      string          `json:"id,omitempty"`
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL