utils

package
v0.0.0-...-9e5a2db Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBuildTimeout = 5 * time.Minute
	DefaultCPUCount     = int32(2)
	DefaultMemoryMB     = int32(1024)
)

Variables

This section is empty.

Functions

func AddUserToTeam

func AddUserToTeam(t *testing.T, db *client.Client, teamID uuid.UUID, userID string)

func BuildSimpleTemplate

func BuildSimpleTemplate(tb testing.TB, names []string, reqEditors ...api.RequestEditorFn) *api.TemplateRequestResponseV3

BuildSimpleTemplate builds a simple template with Ubuntu 22.04 base image

func BuildTemplate

BuildTemplate builds a template with the given options and waits for it to complete

func CreateAPIKey

func CreateAPIKey(t *testing.T, ctx context.Context, c *api.ClientWithResponses, userID string, teamID uuid.UUID) string

func CreateAccessToken

func CreateAccessToken(t *testing.T, db *client.Client, userID uuid.UUID) string

func CreateDir

func CreateDir(tb testing.TB, sbx *api.Sandbox, path string)

func CreateTeam

func CreateTeam(t *testing.T, db *client.Client, teamName string) uuid.UUID

func CreateTeamWithUser

func CreateTeamWithUser(
	t *testing.T,
	db *client.Client,
	teamName, userID string,
) uuid.UUID

func CreateTextFile

func CreateTextFile(tb testing.TB, path string, content string) (*bytes.Buffer, string)

func CreateUser

func CreateUser(t *testing.T, db *client.Client) uuid.UUID

func ExecCommand

func ExecCommand(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, command string, args ...string) error

func ExecCommandAsRoot

func ExecCommandAsRoot(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, command string, args ...string) error

func ExecCommandAsRootWithOutput

func ExecCommandAsRootWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, command string, args ...string) (string, error)

func ExecCommandWithCwd

func ExecCommandWithCwd(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, cwd *string, command string, args ...string) error

func ExecCommandWithOptions

func ExecCommandWithOptions(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, cwd *string, user string, command string, args ...string) error

func ExecCommandWithOutput

func ExecCommandWithOutput(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, cwd *string, user string, command string, args ...string) (string, error)

func NewRequest

func NewRequest(sbx *api.Sandbox, url *url.URL, port int, extraHeaders *http.Header) *http.Request

func SetupSandboxWithCleanup

func SetupSandboxWithCleanup(t *testing.T, c *api.ClientWithResponses, options ...SandboxOption) *api.Sandbox

SetupSandboxWithCleanup creates a new sandbox and returns its data

func TeardownSandbox

func TeardownSandbox(t *testing.T, c *api.ClientWithResponses, sandboxID string)

TeardownSandbox kills the sandbox with the given ID

func UploadFile

func UploadFile(tb testing.TB, ctx context.Context, sbx *api.Sandbox, envdClient *setup.EnvdClient, path string, content string)

func WaitForBuildCompletion

func WaitForBuildCompletion(
	tb testing.TB,
	ctx context.Context,
	templateID string,
	buildID string,
	alias string,
	logHandler BuildLogHandler,
	enableDebug bool,
	reqEditors ...api.RequestEditorFn,
)

WaitForBuildCompletion waits for a template build to complete

func WaitForStatus

func WaitForStatus(tb testing.TB, client *http.Client, sbx *api.Sandbox, url *url.URL, port int, headers *http.Header, expectedStatus int) *http.Response

Types

type BuildLogHandler

type BuildLogHandler func(alias string, entry api.BuildLogEntry)

BuildLogHandler is a function that handles build log entries

func DefaultBuildLogHandler

func DefaultBuildLogHandler(tb testing.TB) BuildLogHandler

DefaultBuildLogHandler returns a default log handler that logs to the test logger

func NoOpBuildLogHandler

func NoOpBuildLogHandler() BuildLogHandler

NoOpBuildLogHandler returns a log handler that does nothing

type SandboxConfig

type SandboxConfig struct {
	// contains filtered or unexported fields
}

type SandboxOption

type SandboxOption func(config *SandboxConfig)

func WithAllowInternetAccess

func WithAllowInternetAccess(allow bool) SandboxOption

func WithAutoPause

func WithAutoPause(autoPause bool) SandboxOption

func WithMetadata

func WithMetadata(metadata api.SandboxMetadata) SandboxOption

func WithNetwork

func WithNetwork(network *api.SandboxNetworkConfig) SandboxOption

func WithSecure

func WithSecure(secure bool) SandboxOption

func WithTemplateID

func WithTemplateID(templateID string) SandboxOption

func WithTimeout

func WithTimeout(timeout int32) SandboxOption

func WithoutAnyMetadata

func WithoutAnyMetadata() SandboxOption

type TemplateBuildOptions

type TemplateBuildOptions struct {
	Names       []string
	CPUCount    *int32
	MemoryMB    *int32
	BuildData   api.TemplateBuildStartV2
	Timeout     time.Duration
	LogHandler  BuildLogHandler
	EnableDebug bool
	ReqEditors  []api.RequestEditorFn
}

TemplateBuildOptions contains options for building a template

Jump to

Keyboard shortcuts

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