api

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TestRunServiceAPIPath = "/api/drift/test_run_service"

Variables

This section is empty.

Functions

func SetupCloud

func SetupCloud(ctx context.Context, requireServiceID bool) (*TuskClient, AuthOptions, *config.Config, error)

Types

type AuthOptions

type AuthOptions struct {
	APIKey       string
	BearerToken  string
	TuskClientID string
}

type Deviation

type Deviation struct {
	Type        string `json:"type"`
	Field       string `json:"field"`
	Expected    any    `json:"expected"`
	Actual      any    `json:"actual"`
	Description string `json:"description"`
	Severity    string `json:"severity"`
}

type MockInteraction

type MockInteraction struct {
	Service   string           `json:"service"`
	Request   RecordedRequest  `json:"request"`
	Response  RecordedResponse `json:"response"`
	Order     int              `json:"order"`
	Timestamp time.Time        `json:"timestamp"`
}

type RecordedRequest

type RecordedRequest struct {
	Method  string              `json:"method"`
	Path    string              `json:"path"`
	Headers map[string][]string `json:"headers"`
	Body    any                 `json:"body,omitempty"`
	Query   map[string][]string `json:"query,omitempty"`
}

type RecordedResponse

type RecordedResponse struct {
	Status  int                 `json:"status"`
	Headers map[string][]string `json:"headers"`
	Body    any                 `json:"body,omitempty"`
}

type TestRecording

type TestRecording struct {
	ID        string            `json:"id"`
	ServiceID string            `json:"service_id"`
	TraceID   string            `json:"trace_id"`
	Method    string            `json:"method"`
	Path      string            `json:"path"`
	Request   RecordedRequest   `json:"request"`
	Response  RecordedResponse  `json:"response"`
	Mocks     []MockInteraction `json:"mocks"`
	Timestamp time.Time         `json:"timestamp"`
	Metadata  map[string]any    `json:"metadata"`
}

type TestResult

type TestResult struct {
	TestID      string      `json:"test_id"`
	ServiceID   string      `json:"service_id"`
	Passed      bool        `json:"passed"`
	Duration    int         `json:"duration_ms"`
	Deviations  []Deviation `json:"deviations,omitempty"`
	Error       string      `json:"error,omitempty"`
	ExecutedAt  time.Time   `json:"executed_at"`
	Environment string      `json:"environment"`
}

type TuskClient

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

func NewClient

func NewClient(baseURL, apiKey string) *TuskClient

func (*TuskClient) CreateDriftRun

func (c *TuskClient) CreateDriftRun(ctx context.Context, in *backend.CreateDriftRunRequest, auth AuthOptions) (string, error)

func (*TuskClient) GetTest

func (c *TuskClient) GetTest(testID string) (*TestRecording, error)

func (*TuskClient) GetTests

func (c *TuskClient) GetTests(serviceID string) ([]TestRecording, error)

Legacy methods - TODO: Remove these once we've migrated to protobuf everywhere

func (*TuskClient) UpdateDriftRunCIStatus

func (c *TuskClient) UpdateDriftRunCIStatus(ctx context.Context, in *backend.UpdateDriftRunCIStatusRequest, auth AuthOptions) error

func (*TuskClient) UploadResults

func (c *TuskClient) UploadResults(results []TestResult) error

func (*TuskClient) UploadTraceTestResults

func (c *TuskClient) UploadTraceTestResults(ctx context.Context, in *backend.UploadTraceTestResultsRequest, auth AuthOptions) error

Jump to

Keyboard shortcuts

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