testhelpers

package
v18.6.0-rc43 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KASUserAgent                 = "kas/v0.1-blabla/asdwd"
	AgentToken    api.AgentToken = "123123"
	AuthSecretKey                = "blablabla"

	ProjectID       int64 = 321
	UserID          int64 = 456
	ConfigProjectID int64 = 5
)

Variables

View Source
var (
	AgentkKey1 = api.AgentKey{
		ID:   123,
		Type: api.AgentTypeKubernetes,
	}
	AgentkKey2 = api.AgentKey{
		ID:   456,
		Type: api.AgentTypeKubernetes,
	}
	AgentwKey1 = api.AgentKey{
		ID:   1123,
		Type: api.AgentTypeWorkspace,
	}
	RunnerControllerKey1 = api.AgentKey{
		ID:   2102,
		Type: api.AgentTypeRunnerController,
	}
)

Functions

func AgentkInfoObj added in v18.2.0

func AgentkInfoObj() *server_api.AgentkInfo

func AgentwInfoObj added in v18.2.0

func AgentwInfoObj() *server_api.AgentwInfo

func AssertAgentToken

func AssertAgentToken(t *testing.T, r *http.Request, agentToken api.AgentToken)

func AssertCommonRequestParams

func AssertCommonRequestParams(t *testing.T, r *http.Request, traceID trace.TraceID)

func AssertGetJSONRequest

func AssertGetJSONRequest(t *testing.T, r *http.Request)

func AssertGetJSONRequestIsCorrect

func AssertGetJSONRequestIsCorrect(t *testing.T, r *http.Request, traceID trace.TraceID)

func AssertGetRequestIsCorrect

func AssertGetRequestIsCorrect(t *testing.T, r *http.Request, traceID trace.TraceID)

func AssertInvalid

func AssertInvalid(t *testing.T, tests []InvalidTestcase)

func AssertJWTSignature

func AssertJWTSignature(t *testing.T, r *http.Request)

func AssertRequestAccept

func AssertRequestAccept(t *testing.T, r *http.Request, accept string)

func AssertRequestAcceptJSON

func AssertRequestAcceptJSON(t *testing.T, r *http.Request)

func AssertRequestContentTypeJSON

func AssertRequestContentTypeJSON(t *testing.T, r *http.Request) bool

func AssertRequestMethod

func AssertRequestMethod(t *testing.T, r *http.Request, method string)

func AssertRequestUserAgent

func AssertRequestUserAgent(t *testing.T, r *http.Request, userAgent string)

func AssertValid

func AssertValid(t *testing.T, tests []ValidTestcase)

func CtxWithSpanContext

func CtxWithSpanContext(t *testing.T) (context.Context, trace.TraceID)

func GenerateCACert

func GenerateCACert(t *testing.T) (string, string, *x509.Certificate, crypto.PrivateKey)

func GenerateCert

func GenerateCert(t *testing.T, name string, caCert *x509.Certificate, caKey crypto.PrivateKey) (string, string)

func InjectSpanContext

func InjectSpanContext(t *testing.T, ctx context.Context) (context.Context, trace.TraceID)

func NewPollConfig

func NewPollConfig(interval time.Duration) retry.PollConfig

func ReadProtoJSONRequest

func ReadProtoJSONRequest(t *testing.T, r *http.Request, m proto.Message) bool

func RecvMsg

func RecvMsg(value any) func(any) error

func RespondWithJSON

func RespondWithJSON(t *testing.T, w http.ResponseWriter, response any)

RespondWithJSON marshals response into JSON and writes it into w.

func RunnerControllerInfoObj added in v18.6.0

func RunnerControllerInfoObj() *server_api.RunnerControllerInfo

func SetValue

func SetValue(target, value any)

SetValue sets target to value with special handling for proto.Message. target must be a pointer. i.e. *blaProtoMsgType value must be of the same type as target.

Types

type InvalidTestcase

type InvalidTestcase struct {
	ErrString string
	Invalid   proto.Message
}

type ValidTestcase

type ValidTestcase struct {
	Name  string
	Valid proto.Message
}

Jump to

Keyboard shortcuts

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