test

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

package test temporarily contains all commonly used, generic utils for testing.

Index

Constants

View Source
const (
	LOCAL environment = "local"
	STG   environment = "staging"
	PROD  environment = "production"
)
View Source
const (
	SEVERITY_LOG_PREFIX = "Severity#"
)

Variables

View Source
var TestCfg = TestConfig{}

Functions

func NewHTTPClientWithRetry

func NewHTTPClientWithRetry() *resty.Client

NewHTTPClientWithRetry returns a http client with retry mechanism

func NewHTTPClientWithoutRetry

func NewHTTPClientWithoutRetry() *resty.Client

NewHTTPClientWithoutRetry returns a http client without retry mechanism

func SetSeverity

func SetSeverity(t *testing.T, s Severity)

SetSeverity sets the severity of a test.

func SetupConfig

func SetupConfig(configPath string, opts ...CfgOption) error

SetupConfig initializes the configuration and accepts optional configuration functions. please ensure that config file contains `test` section.

func SetupConfigWithFixture

func SetupConfigWithFixture[T any](configPath string, custom *T) error

SetupConfigWithFixture initializes the configuration and custom fixture. It finally overwrites a given fixture as argument with an initialized one which should have some values you set beforehand. please ensure that config file contains `test` section and `fixture` section there.

func SkipTestIfInSkipList

func SkipTestIfInSkipList(t *testing.T, testName string)

Types

type CfgOption

type CfgOption func(*TestConfig)

func WithFixture

func WithFixture[T any](custom T) CfgOption

WithFixture is an option function to set the Fixture

type RespBody

type RespBody struct {
	ErrorCode string                 `json:"errorCode,omitempty"`
	Data      map[string]interface{} `json:"data,omitempty"`
}

RespBody is a common response body.

func UnmarshalRespBody

func UnmarshalRespBody(t *testing.T, respBody []byte) RespBody

type Severity

type Severity string

Severity represents the level of importance or urgency of a test. It helps developers prioritize which tests to investigate first when some tests fails.

const (
	CRITICAL Severity = "Critical"
	HIGH     Severity = "High"
	MEDIUM   Severity = "Medium"
	LOW      Severity = "Low"
	TRIVIAL  Severity = "Trivial"
	NO_SET   Severity = "No_Set"
)

type TestConfig

type TestConfig struct {
	Skip       []string
	HTTPClient struct {
		Timeout          time.Duration
		RetryCount       int
		RetryWaitTime    time.Duration
		RetryMaxWaitTime time.Duration
	}
	Fixture any
}

Jump to

Keyboard shortcuts

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