testutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package testutil contains shared helpers for offline and live test execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockBetaClient added in v1.3.4

func NewMockBetaClient(t *testing.T, server *MockDeepSeekServer, opts ...deepseek.Option) *deepseek.Client

NewMockBetaClient creates a client configured to talk to the mock server's beta API endpoints.

func NewMockClient added in v1.3.4

func NewMockClient(t *testing.T, server *MockDeepSeekServer, opts ...deepseek.Option) *deepseek.Client

NewMockClient creates a client configured to talk to the mock server's standard API endpoints.

func SkipIfShort

func SkipIfShort(t *testing.T)

SkipIfShort skips long-running tests when -short flag is used

func SkipUnlessLiveAPI added in v1.3.4

func SkipUnlessLiveAPI(t *testing.T)

SkipUnlessLiveAPI skips tests unless the live API opt-in flag is enabled.

func WriteJSON added in v1.3.4

func WriteJSON(t *testing.T, w http.ResponseWriter, status int, body interface{})

WriteJSON writes a JSON response and fails the test immediately if encoding fails.

func WriteSSE added in v1.3.4

func WriteSSE(t *testing.T, w http.ResponseWriter, chunks ...string)

WriteSSE writes a simple server-sent event stream terminated by a `[DONE]` frame.

Types

type MockDeepSeekServer added in v1.3.4

type MockDeepSeekServer struct {
	*httptest.Server
}

func NewMockDeepSeekServer added in v1.3.4

func NewMockDeepSeekServer(t *testing.T) *MockDeepSeekServer

NewMockDeepSeekServer creates a local HTTP server that mimics the small subset of DeepSeek endpoints used by tests.

func (*MockDeepSeekServer) BaseURL added in v1.3.4

func (s *MockDeepSeekServer) BaseURL() string

BaseURL returns the mock server base URL for standard API endpoints.

func (*MockDeepSeekServer) BetaBaseURL added in v1.3.4

func (s *MockDeepSeekServer) BetaBaseURL() string

BetaBaseURL returns the mock server base URL for beta endpoints.

type TestConfig

type TestConfig struct {
	APIKey      string
	TestTimeout time.Duration
}

TestConfig holds test configuration loaded from environment

func LoadTestConfig

func LoadTestConfig(t *testing.T) *TestConfig

LoadTestConfig loads test configuration from environment variables

Jump to

Keyboard shortcuts

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