helper

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProxyHttpURL  = "http://localhost:9700"
	ProxyHttpsURL = "https://localhost:9700"
	AdminHttpURL  = "http://localhost:9701"
	AdminHttpsURL = "https://localhost:9701"
	StatusHttpURL = "http://localhost:9702"

	LogFile                  = test.FilePath("webhookx.log")
	OtelCollectorTracesFile  = test.FilePath("output/otel/traces.json")
	OtelCollectorMetricsFile = test.FilePath("output/otel/metrics.json")

	// Environments is default test environments
	Environments = map[string]string{
		"NO_COLOR":                           "true",
		"WEBHOOKX_LOG_LEVEL":                 "debug",
		"WEBHOOKX_LOG_FORMAT":                "text",
		"WEBHOOKX_LOG_FILE":                  LogFile,
		"WEBHOOKX_LOG_COLORED":               "false",
		"WEBHOOKX_ACCESS_LOG_FILE":           LogFile,
		"WEBHOOKX_ACCESS_LOG_COLORED":        "false",
		"WEBHOOKX_WORKER_DELIVERER_ACL_DENY": "",
		"WEBHOOKX_PROXY_LISTEN":              "127.0.0.1:9700",
		"WEBHOOKX_ADMIN_LISTEN":              "127.0.0.1:9701",
		"WEBHOOKX_STATUS_LISTEN":             "127.0.0.1:9702",
		"WEBHOOKX_DATABASE_DATABASE":         "webhookx_test",
		"WEBHOOKX_DATABASE_MAX_POOL_SIZE":    "20",
		"WEBHOOKX_DATABASE_MAX_LIFETIME":     "60",
		"WEBHOOKX_WORKER_POOL_SIZE":          "100",
		"WEBHOOKX_WORKER_POOL_CONCURRENCY":   "10",
	}
)

Functions

func AdminClient

func AdminClient() *resty.Client

func AdminTLSClient added in v0.5.0

func AdminTLSClient() *resty.Client

func ClearEnvironments added in v1.0.0

func ClearEnvironments(envs map[string]string)

func Env added in v1.0.1

func Env() map[string]string

func ExecAppCommand added in v1.0.0

func ExecAppCommand(args ...string) (output string, err error)

ExecAppCommand executes application command

func FileCountLine added in v0.3.0

func FileCountLine(filename string) (int, error)

func FileHasLine added in v0.3.0

func FileHasLine(filename string, regex string) (bool, error)

func FileLine

func FileLine(filename string, n int) (string, error)

func GenerateTraceID added in v0.4.0

func GenerateTraceID() string

func GetDeafultWorkspace added in v0.4.0

func GetDeafultWorkspace() (*entities.Workspace, error)

func InitDB

func InitDB(truncated bool, entities *TestEntities) *db.DB

func InitOtelOutput added in v0.4.0

func InitOtelOutput()

func LoadConfig added in v1.0.0

func LoadConfig(opts LoadConfigOptions) (*config.Config, error)

func MustStart added in v1.0.0

func MustStart(envs map[string]string, opts ...Option) *app.Application

func NewDB added in v1.0.0

func NewDB(cfg *config.Config) *db.DB

func NewTestEnv added in v1.0.0

func NewTestEnv(sets map[string]string) map[string]string

NewTestEnv returns a map that with default test environment variables set.

func PathExist added in v0.4.0

func PathExist(_path string) bool

func ProxyClient

func ProxyClient() *resty.Client

func ProxyTLSClient added in v0.5.0

func ProxyTLSClient() *resty.Client

func ReplaceLicenser added in v1.0.0

func ReplaceLicenser(licenser license.Licenser) func()

func SecretManangerClient added in v1.0.0

func SecretManangerClient() *secretsmanager.Client

func SetEnvironments added in v1.0.0

func SetEnvironments(envs map[string]string)

func SetEnvs added in v1.0.0

func SetEnvs(sets map[string]string) func()

SetEnvs sets env variables and returns a function to restore environment variables

func Start

func Start(envs map[string]string, opts ...Option) (application *app.Application, err error)

Start starts application with given environment variables

func StartHttpServer added in v1.0.0

func StartHttpServer(handler http.HandlerFunc, addr string) *http.Server

func StatusClient added in v0.8.0

func StatusClient() *resty.Client

func TruncateFile

func TruncateFile(filename string) error

func VaultClient added in v1.0.0

func VaultClient() *vault.Client

func WaitForServer added in v1.0.0

func WaitForServer(urlstring string, timeout time.Duration) error

Types

type LoadConfigOptions added in v1.0.0

type LoadConfigOptions struct {
	Envs       map[string]string
	File       string
	ExcludeEnv bool
}

type MockLicenser added in v1.0.0

type MockLicenser struct{}

func (*MockLicenser) Allow added in v1.0.0

func (l *MockLicenser) Allow(feature string) bool

func (*MockLicenser) AllowAPI added in v1.0.0

func (l *MockLicenser) AllowAPI(workspace string, path string, method string) bool

func (*MockLicenser) AllowPlugin added in v1.0.0

func (l *MockLicenser) AllowPlugin(plugin string) bool

func (*MockLicenser) License added in v1.0.0

func (l *MockLicenser) License() *apilicense.License

type Option added in v1.0.0

type Option func(*Options)

func WithLicenser added in v1.0.0

func WithLicenser(licenser license.Licenser) Option

type Options added in v1.0.0

type Options struct {
	Licenser license.Licenser
}

type TestEntities added in v1.0.0

type TestEntities struct {
	Endpoints      []*entities.Endpoint
	Sources        []*entities.Source
	Events         []*entities.Event
	Attempts       []*entities.Attempt
	AttemptDetails []*entities.AttemptDetail
	Plugins        []*entities.Plugin
}

func (*TestEntities) AddAttempt added in v1.0.0

func (t *TestEntities) AddAttempt(attempt *entities.Attempt)

func (*TestEntities) AddAttemptDetail added in v1.0.0

func (t *TestEntities) AddAttemptDetail(attemptDetail *entities.AttemptDetail)

func (*TestEntities) AddEndpoint added in v1.0.0

func (t *TestEntities) AddEndpoint(endpoint *entities.Endpoint)

func (*TestEntities) AddEvent added in v1.0.0

func (t *TestEntities) AddEvent(event *entities.Event)

func (*TestEntities) AddPlugin added in v1.0.0

func (t *TestEntities) AddPlugin(plugin *entities.Plugin)

func (*TestEntities) AddSource added in v1.0.0

func (t *TestEntities) AddSource(source *entities.Source)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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