client

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login() error

func Logout

func Logout(accessToken string, apiURL string) error

Types

type AuthRequest

type AuthRequest struct {
	Otp string `json:"otp"`
}

type AuthResponse

type AuthResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
	ExpiresIn    int    `json:"expiresIn"`
	UserId       int    `json:"userId"`
	Username     string `json:"username"`
	Email        string `json:"email"`
}

func LoginWithCode

func LoginWithCode(otp string, apiURL string) (*AuthResponse, error)

func RefreshToken

func RefreshToken(refreshToken string, apiURL string) (*AuthResponse, error)

type CascadedTestConfig

type CascadedTestConfig struct {
	TargetStageUuid   string          `json:"targetStageUuid"`
	TargetStageNumber int             `json:"targetStageNumber"`
	StagesToRun       []StageTestInfo `json:"stagesToRun"`
}

CascadedTestConfig represents test configurations for multiple stages When requesting stage X, this contains tests for stages 1..X

func FetchCascadedTests

func FetchCascadedTests(stageUuid string, cfg *config.Config) (*CascadedTestConfig, error)

FetchCascadedTests fetches test configurations for all prerequisite stages When requesting stage X, this returns tests for stages 1..X to ensure backward compatibility

type FileCreation

type FileCreation struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

Define a new struct for the file items

type HttpError

type HttpError struct {
	StatusCode int
	Body       string
}

func (*HttpError) Error

func (e *HttpError) Error() string

type HttpRequest

type HttpRequest struct {
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Headers map[string]string `json:"headers"`
	Body    string            `json:"body"`
}

type HttpResponse

type HttpResponse struct {
	StatusCode int               `json:"statusCode"`
	Body       string            `json:"body"`
	Headers    map[string]string `json:"headers"`
}

type ProgramConfig

type ProgramConfig struct {
	Executable string            `json:"executable"`
	Args       []string          `json:"args"`
	Env        map[string]string `json:"env"`
}

ProgramConfig defines how to run the user's program for HTTP tests

type ServerConfig

type ServerConfig struct {
	Port          int `json:"port"`
	StartupWaitMs int `json:"startupWaitMs"`
}

ServerConfig defines the server parameters for HTTP tests

type StageTestInfo

type StageTestInfo struct {
	StageUuid   string `json:"stageUuid"`
	StageNumber int    `json:"stageNumber"`
	StageName   string `json:"stageName"`
	TestConfig  string `json:"testConfig"` // JSON string
}

type SubmissionRequest

type SubmissionRequest struct {
	StageUuid         string       `json:"stageUuid"`
	Language          string       `json:"language"`
	TestResults       []TestResult `json:"testResults"`
	TargetStageNumber *int         `json:"targetStageNumber"`
}

type SubmissionResult

type SubmissionResult struct {
	Passed       bool          `json:"passed"`
	TotalTests   int           `json:"totalTests"`
	PassedTests  int           `json:"passedTests"`
	FailedTests  int           `json:"failedTests"`
	Feedback     string        `json:"feedback"`
	TestFailures []TestFailure `json:"testFailures"`
}

func SubmitResults

func SubmitResults(stageUuid string, language string, cfg *config.Config, results []TestResult, targetStageNumber *int) (*SubmissionResult, error)

type Test

type Test struct {
	TestName       string `json:"testName"`
	Stdin          string `json:"stdin"`
	TimeoutSeconds int    `json:"timeoutSeconds"`
	// in case testType is "http_server"
	HttpRequests []HttpRequest `json:"httpRequests"`
	// Setup and cleanup operations
	Setup   *TestSetup   `json:"setup"`
	Cleanup *TestCleanup `json:"cleanup"`
}

type TestCleanup

type TestCleanup struct {
	DeleteDirs  []string `json:"deleteDirs"`
	DeleteFiles []string `json:"deleteFiles"`
}

TestCleanup defines operations to perform after running a test

type TestConfig

type TestConfig struct {
	StageName     string         `json:"stageName"`
	TestType      string         `json:"testType"` // "cli_interactive" or "http_server"
	ProgramConfig *ProgramConfig `json:"programConfig"`
	ServerConfig  *ServerConfig  `json:"serverConfig"`
	Tests         []Test         `json:"tests"`
}

func FetchTests

func FetchTests(stageUuid string, cfg *config.Config) (*TestConfig, error)

FetchTests is kept for backward compatibility but now uses the cascaded endpoint Returns only the tests for the requested stage

func ParseStageTests

func ParseStageTests(stageInfo StageTestInfo) (*TestConfig, error)

ParseStageTests parses the test config JSON string for a single stage

type TestFailure

type TestFailure struct {
	TestName string `json:"testName"`
	Reason   string `json:"reason"`
}

type TestResult

type TestResult struct {
	TestName      string         `json:"testName"`
	ExitCode      int            `json:"exitCode"`
	Stdout        string         `json:"stdout"`
	Stderr        string         `json:"stderr"`
	HttpResponses []HttpResponse `json:"httpResponses"`
}

type TestSetup

type TestSetup struct {
	CreateDirs []string `json:"createDirs"`
	// Change this from map[string]string to []FileCreation
	CreateFiles []FileCreation `json:"createFiles"`
	DeleteFiles []string       `json:"deleteFiles"`
	DeleteDirs  []string       `json:"deleteDirs"`
}

TestSetup defines operations to perform before running a test

Jump to

Keyboard shortcuts

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