apitest

package
v0.158.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Kind represents the type definition of this config.
	Kind = "apitest"

	// APIVersion represents the supported config version.
	APIVersion = "v1alpha"
)

Config descriptors.

View Source
var (
	ErrEventNotFound = errors.New("event not found")
)

Functions

func FilterSuites added in v0.117.0

func FilterSuites(p *Project, suiteName string) error

FilterSuites filters out suites in the project that don't match the given suite name.

func SetDefaults

func SetDefaults(p *Project)

SetDefaults applies config defaults in case the user has left them blank.

func Validate

func Validate(p Project) error

Types

type APITester added in v0.124.1

type APITester interface {
	GetProject(ctx context.Context, hookID string) (ProjectMeta, error)
	GetEventResult(ctx context.Context, hookID string, eventID string) (TestResult, error)
	GetTest(ctx context.Context, hookID string, testID string) (Test, error)
	GetProjects(ctx context.Context) ([]ProjectMeta, error)
	GetHooks(ctx context.Context, projectID string) ([]Hook, error)
	RunAllAsync(ctx context.Context, hookID string, buildID string, tunnel config.Tunnel, test TestRequest) (AsyncResponse, error)
	RunEphemeralAsync(ctx context.Context, hookID string, buildID string, tunnel config.Tunnel, taskID string, test TestRequest) (AsyncResponse, error)
	RunTestAsync(ctx context.Context, hookID string, testID string, buildID string, tunnel config.Tunnel, test TestRequest) (AsyncResponse, error)
	RunTagAsync(ctx context.Context, hookID string, testTag string, buildID string, tunnel config.Tunnel, test TestRequest) (AsyncResponse, error)
}

type AsyncResponse added in v0.124.1

type AsyncResponse struct {
	ContextIDs []string `json:"contextIds,omitempty"`
	EventIDs   []string `json:"eventIds,omitempty"`
	TaskID     string   `json:"taskId,omitempty"`
	TestIDs    []string `json:"testIds,omitempty"`
}

AsyncResponse describes the json response from the async api endpoints.

type Hook added in v0.124.1

type Hook struct {
	Identifier string `json:"identifier,omitempty"`
	Name       string `json:"name,omitempty"`
}

Hook describes the metadata for a hook.

type Project

type Project struct {
	config.TypeDef `yaml:",inline" mapstructure:",squash"`
	ConfigFilePath string             `yaml:"-" json:"-"`
	DryRun         bool               `yaml:"-" json:"-"`
	Suites         []Suite            `yaml:"suites,omitempty"`
	Sauce          config.SauceConfig `yaml:"sauce,omitempty"`
	RootDir        string             `yaml:"rootDir,omitempty"`
	Env            map[string]string  `yaml:"env,omitempty"`
}

Project represents the apitest project configuration.

func FromFile

func FromFile(cfgPath string) (Project, error)

FromFile creates a new apitest Project based on the filepath cfgPath.

type ProjectMeta added in v0.124.1

type ProjectMeta struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

ProjectMeta describes the metadata for an api testing project.

type Runner

type Runner struct {
	Project       Project
	Client        APITester
	Region        region.Region
	Reporters     []report.Reporter
	Async         bool
	TunnelService tunnel.Service
}

Runner represents an executor for api tests

func (*Runner) ResolveHookIDs added in v0.122.0

func (r *Runner) ResolveHookIDs() error

ResolveHookIDs resolve, for each suite, the matching hookID.

func (*Runner) RunProject

func (r *Runner) RunProject() (int, error)

RunProject runs the tests defined in apitest.Project

type Suite

type Suite struct {
	Timeout        time.Duration     `yaml:"timeout,omitempty"`
	Name           string            `yaml:"name,omitempty"`
	ProjectName    string            `yaml:"projectName,omitempty"`
	UseRemoteTests bool              `yaml:"useRemoteTests,omitempty"`
	Tests          []string          `yaml:"tests,omitempty"`
	Tags           []string          `yaml:"tags,omitempty"`
	TestMatch      []string          `yaml:"testMatch,omitempty"`
	Env            map[string]string `yaml:"env,omitempty"`

	// HookID is a technical ID unique to a project that's required by the APIs
	// that execute API tests. The HookID is retrieved dynamically based on
	// ProjectName before calling those endpoints.
	HookID string `yaml:"-"`

	// ProjectID is a technical ID unique to a project that's required by the
	// APIs that execute API tests. The ProjectID is retrieved dynamically based
	// on ProjectName before calling those endpoints.
	ProjectID string `yaml:"-"`
}

Suite represents the apitest suite configuration.

type Test added in v0.124.1

type Test struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Test describes a single test.

type TestRequest added in v0.124.1

type TestRequest struct {
	Name   string            `json:"name"`
	Tags   []string          `json:"tags"`
	Input  string            `json:"input"`
	Unit   string            `json:"unit"`
	Params map[string]string `json:"params"`
}

TestRequest represent a test to be executed

type TestResult added in v0.124.1

type TestResult struct {
	EventID              string      `json:"_id,omitempty"`
	FailuresCount        int         `json:"failuresCount,omitempty"`
	Project              ProjectMeta `json:"project,omitempty"`
	Test                 Test        `json:"test,omitempty"`
	ExecutionTimeSeconds int         `json:"executionTimeSeconds,omitempty"`
	Async                bool        `json:"-"`
	TimedOut             bool        `json:"-"`
	Error                error       `json:"-"`
}

TestResult describes the result from running an api test.

type Vault added in v0.144.0

type Vault struct {
	Variables []VaultVariable   `json:"variables"`
	Snippets  map[string]string `json:"snippets"`
}

Vault represents a project's stored variables and snippets

type VaultFile added in v0.147.0

type VaultFile struct {
	ID        string `json:"id"`
	CreatedAt int64  `json:"createdAt"`
	UpdatedAt int64  `json:"updatedAt"`
	CompanyID string `json:"companyId"`
	ProjectID string `json:"projectId"`
	Name      string `json:"name"`
	Size      int    `json:"size"`
	Source    string `json:"source"`
	IsOpenAPI bool   `json:"isOpenAPI"`
}

VaultFile represents a file stored in a project vault

type VaultVariable added in v0.144.0

type VaultVariable struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
	Type  string `json:"type,omitempty"`
}

VaultVariable represents a variable stored in a project vault

Jump to

Keyboard shortcuts

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