Documentation ¶
Index ¶
- Constants
- func GetPackageName(packageNameStruct any) string
- func IsNatsContainerised() bool
- func IsNatsPersist() bool
- func IsSharContainerised() bool
- func RegisterTaskYamlFile(ctx context.Context, cl *client.Client, filename string, fn client.ServiceFn) (string, error)
- func WaitForChan(t *testing.T, c chan struct{}, d time.Duration)
- func WaitForExpectedCompletions(t *testing.T, expectedCompletions int, completion chan struct{}, ...)
- type Integration
- func (s *Integration) AssertCleanKV(namespce string, t *testing.T, cooldown time.Duration)
- func (s *Integration) GetJetstream() (jetstream.JetStream, error)
- func (s *Integration) GetNats() (*nats.Conn, error)
- func (s *Integration) Setup()
- func (s *Integration) Teardown()
- func (s *Integration) TrackingUpdatesFor(namespace string, executionId string, received chan struct{}, ...)
Constants ¶
const ( // NATS_SERVER_IMAGE_URL_ENV_VAR_NAME is the name of the env var containing the nats image URL NATS_SERVER_IMAGE_URL_ENV_VAR_NAME = "NATS_SERVER_IMAGE_URL" // SHAR_SERVER_IMAGE_URL_ENV_VAR_NAME is the name of the env var containing the shar server image URL SHAR_SERVER_IMAGE_URL_ENV_VAR_NAME = "SHAR_SERVER_IMAGE_URL" // NATS_PERSIST_ENV_VAR_NAME is the name of the env var containing the flag determining whether nats data is persisted between tests NATS_PERSIST_ENV_VAR_NAME = "NATS_PERSIST" )
Variables ¶
This section is empty.
Functions ¶
func GetPackageName ¶
GetPackageName retrieves the name of a package a particular struct is declared in
func IsNatsContainerised ¶
func IsNatsContainerised() bool
IsNatsContainerised determines whether tests are running against containerised nats server
func IsNatsPersist ¶
func IsNatsPersist() bool
IsNatsPersist determines whether tests are persist nats data between executions
func IsSharContainerised ¶
func IsSharContainerised() bool
IsSharContainerised determines whether tests are running against containerised shar server
func RegisterTaskYamlFile ¶
func RegisterTaskYamlFile(ctx context.Context, cl *client.Client, filename string, fn client.ServiceFn) (string, error)
RegisterTaskYamlFile is used by integration tests to register a service task and function from a YAML file. It first loads and registers the task using taskutil.LoadTaskFromYamlFile, and then registers the task function using taskutil.RegisterTaskFunctionFromYamlFile. It is not recommended to call the functions in succession in real world scenarios as it will cause a task version race condition. Instead, call taskutil.LoadTaskFromYamlFile from an external application, and use taskutil.RegisterTaskFunctionFromYamlFile inside the service task to register the function
func WaitForChan ¶
WaitForChan waits for a chan struct{} with a duration timeout.
Types ¶
type Integration ¶
type Integration struct { FinalVars map[string]interface{} Mx sync.Mutex Cooldown time.Duration WithTelemetry server2.Exporter WithTrace bool NatsURL string // NatsURL is the default testing URL for the NATS host. TestRunnable func() (bool, string) // contains filtered or unexported fields }
Integration - the integration test support framework.
func NewIntegration ¶
func NewIntegration(trace bool, packageName string, WithTelemetry server2.Exporter) *Integration
NewIntegration is used to construct an instance of Integration support used from the context of a package
func NewIntegrationT ¶
func NewIntegrationT(t *testing.T, authZFn authz.APIFunc, authNFn authn.Check, trace bool, testRunnableFn func() (bool, string), WithTelemetry server2.Exporter) *Integration
NewIntegrationT is used to construct an instance of Integration support used from the context of a test
func (*Integration) AssertCleanKV ¶
AssertCleanKV - ensures SHAR has cleans up after itself, and there are no records left in the KV.
func (*Integration) GetJetstream ¶
func (s *Integration) GetJetstream() (jetstream.JetStream, error)
GetJetstream - fetches the test framework jetstream server for making test calls.
func (*Integration) GetNats ¶
func (s *Integration) GetNats() (*nats.Conn, error)
GetNats - fetches the test framework NATS server for making test calls.
func (*Integration) Setup ¶
func (s *Integration) Setup()
Setup - sets up the test NATS and SHAR servers.
func (*Integration) Teardown ¶
func (s *Integration) Teardown()
Teardown - resposible for shutting down the integration test framework.
func (*Integration) TrackingUpdatesFor ¶
func (s *Integration) TrackingUpdatesFor(namespace string, executionId string, received chan struct{}, duration time.Duration, t *testing.T)
TrackingUpdatesFor sends to the received channel when tracking updates for a given namespace and execution id are received