Documentation
¶
Overview ¶
Package testutil provides shared fixtures for CLI integration testing
Package testutil provides shared utilities for CLI testing
Index ¶
- Variables
- func AssertContains(t *testing.T, s, substr string)
- func AssertEqual(t *testing.T, got, want interface{})
- func AssertError(t *testing.T, err error)
- func AssertNoError(t *testing.T, err error)
- func TempDir(t *testing.T) string
- func WriteFile(t *testing.T, dir, name, content string) string
- type APIMeta
- type APIResponse
- type CaptureOutput
- type CompanyCompact
- type DateResponse
- type MockAPIServer
- type MockResponse
- type NotificationResponse
- type ProjectCompact
- type ProjectCompany
- type ProjectDates
- type ProjectResponse
- type ProjectSettings
- type ProjectStats
- type ProjectStatus
- type SprintCompact
- type SprintResponse
- type SprintStats
- type SprintStatus
- type SprintTimebox
- type TaskResponse
- type TaskSettings
- type TaskStats
- type TimeTrackingResponse
- type TimeTrackingTime
- type UserResponse
- type WorkflowResponse
Constants ¶
This section is empty.
Variables ¶
var Fixtures = struct { Task TaskResponse Tasks []TaskResponse Project ProjectResponse Projects []ProjectResponse Sprint SprintResponse Sprints []SprintResponse TimeTracker TimeTrackingResponse User UserResponse }{ User: UserResponse{ UUID: "550e8400-e29b-41d4-a716-446655440001", Username: "johndoe", Name: "John Doe", Email: "john@example.com", Photo: nil, }, Task: TaskResponse{ UUID: "550e8400-e29b-41d4-a716-446655440000", Code: "GS-123", Slug: "fix-login-issue", Title: "Fix login issue on mobile", Description: "Users cannot login on iOS devices", State: "open", Workflow: &WorkflowResponse{ Slug: "in-progress", Title: "In Progress", Color: "#3498db", }, Settings: TaskSettings{ IsBlocker: false, IsBug: true, IsDraft: false, }, Stats: TaskStats{ Votes: 5, Comments: 3, Attachments: 2, Subtasks: 4, }, Project: &ProjectCompact{ Slug: "mobile-app", Name: "Mobile App", }, }, Tasks: []TaskResponse{ { UUID: "550e8400-e29b-41d4-a716-446655440000", Code: "GS-123", Slug: "fix-login-issue", Title: "Fix login issue on mobile", State: "open", Workflow: &WorkflowResponse{ Slug: "in-progress", Title: "In Progress", Color: "#3498db", }, }, { UUID: "550e8400-e29b-41d4-a716-446655440002", Code: "GS-124", Slug: "add-dark-mode", Title: "Add dark mode support", State: "open", Workflow: &WorkflowResponse{ Slug: "todo", Title: "To Do", Color: "#95a5a6", }, }, { UUID: "550e8400-e29b-41d4-a716-446655440003", Code: "GS-125", Slug: "optimize-performance", Title: "Optimize app performance", State: "closed", Workflow: &WorkflowResponse{ Slug: "done", Title: "Done", Color: "#27ae60", }, }, }, Project: ProjectResponse{ ID: 1, UUID: "660e8400-e29b-41d4-a716-446655440000", Slug: "mobile-app", Name: "Mobile App", Description: "Our flagship mobile application", Code: "MA", Company: &ProjectCompany{ UUID: "770e8400-e29b-41d4-a716-446655440000", Slug: "acme-corp", Name: "ACME Corporation", }, Stats: ProjectStats{ Total: 50, Open: 20, Progress: 15, Closed: 15, }, Settings: ProjectSettings{ UseTimer: true, TaskType: true, ShowNumber: true, HasSprints: true, HasWiki: true, }, Status: ProjectStatus{ Code: "active", Title: "Active", }, }, Projects: []ProjectResponse{ { ID: 1, UUID: "660e8400-e29b-41d4-a716-446655440000", Slug: "mobile-app", Name: "Mobile App", Stats: ProjectStats{ Total: 50, Open: 20, Progress: 15, Closed: 15, }, }, { ID: 2, UUID: "660e8400-e29b-41d4-a716-446655440001", Slug: "web-platform", Name: "Web Platform", Stats: ProjectStats{ Total: 120, Open: 45, Progress: 30, Closed: 45, }, }, }, Sprint: SprintResponse{ ID: 1, Code: "SPR-1", Slug: "sprint-1-2024", Title: "Sprint 1 - February 2024", Color: "#3498db", Description: "First sprint of Q1", Duration: 14, Timebox: SprintTimebox{ Start: &DateResponse{Date: "2024-02-01", Timezone: "UTC", Ago: "6 days ago"}, Finish: &DateResponse{Date: "2024-02-14", Timezone: "UTC", Ago: "in 8 days"}, }, Stats: SprintStats{ StoryPoints: 21, WorkedHours: 45, TotalTasks: 15, ClosedTasks: 8, Percentage: 53, Comments: 25, }, Status: SprintStatus{ Slug: "sprint-open", Title: "Open", Color: "079a0d", }, Project: &ProjectCompact{ Slug: "mobile-app", Name: "Mobile App", }, }, Sprints: []SprintResponse{ { ID: 1, Code: "SPR-1", Slug: "sprint-1-2024", Title: "Sprint 1 - February 2024", Duration: 14, Stats: SprintStats{TotalTasks: 15, ClosedTasks: 8, Percentage: 53}, Status: SprintStatus{Slug: "sprint-open", Title: "Open"}, }, { ID: 2, Code: "SPR-2", Slug: "sprint-2-2024", Title: "Sprint 2 - February 2024", Duration: 14, Stats: SprintStats{TotalTasks: 20, ClosedTasks: 0, Percentage: 0}, Status: SprintStatus{Slug: "sprint-planned", Title: "Planned"}, }, }, TimeTracker: TimeTrackingResponse{ Comment: "Working on login fix", Time: TimeTrackingTime{ ID: 1, Total: "02:30:00", DurationMinutes: 150, }, Billed: false, IsBillable: true, }, }
Fixtures provides pre-configured test data
Functions ¶
func AssertContains ¶
AssertContains fails if s does not contain substr
func AssertEqual ¶
AssertEqual fails if got != want
func AssertError ¶
AssertError fails the test if err is nil
func AssertNoError ¶
AssertNoError fails the test if err is not nil
Types ¶
type APIResponse ¶
type APIResponse struct {
Data interface{} `json:"data"`
Meta *APIMeta `json:"meta,omitempty"`
}
APIResponse wraps API responses
type CaptureOutput ¶
type CaptureOutput struct {
// contains filtered or unexported fields
}
CaptureOutput captures stdout/stderr during test execution
func NewCaptureOutput ¶
func NewCaptureOutput() *CaptureOutput
NewCaptureOutput starts capturing stdout
func (*CaptureOutput) Stop ¶
func (c *CaptureOutput) Stop() string
Stop stops capturing and returns the captured output
type CompanyCompact ¶
type DateResponse ¶
type DateResponse struct {
Date string `json:"date"`
Timezone string `json:"timezone"`
Ago string `json:"ago"`
}
DateResponse represents a date from the API (based on DateResource)
type MockAPIServer ¶
type MockAPIServer struct {
*httptest.Server
Responses map[string]MockResponse
}
MockAPIServer creates a test HTTP server with configurable responses
func NewMockAPIServer ¶
func NewMockAPIServer(responses map[string]MockResponse) *MockAPIServer
NewMockAPIServer creates a new mock server
func (*MockAPIServer) Client ¶
func (m *MockAPIServer) Client() *api.Client
Client returns an API client configured for this mock server
func (*MockAPIServer) UnauthenticatedClient ¶
func (m *MockAPIServer) UnauthenticatedClient() *api.Client
UnauthenticatedClient returns an API client without auth
type MockResponse ¶
MockResponse defines a mock API response
type NotificationResponse ¶
type NotificationResponse struct {
UUID string `json:"uuid"`
Type string `json:"type"`
Title string `json:"title"`
Message string `json:"message"`
ReadAt *DateResponse `json:"read_at"`
CreatedAt *DateResponse `json:"created_at"`
}
NotificationResponse represents a notification
type ProjectCompact ¶
type ProjectCompany ¶
type ProjectDates ¶
type ProjectDates struct {
Start *DateResponse `json:"start"`
Due *DateResponse `json:"due"`
}
type ProjectResponse ¶
type ProjectResponse struct {
ID int `json:"id"`
UUID string `json:"uuid"`
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
Code string `json:"code"`
Logo string `json:"logo"`
Company *ProjectCompany `json:"company"`
Stats ProjectStats `json:"stats"`
Settings ProjectSettings `json:"settings"`
Status ProjectStatus `json:"status"`
Dates ProjectDates `json:"dates"`
Users []UserResponse `json:"users"`
CreatedAt *DateResponse `json:"created_at"`
}
ProjectResponse represents a project from the API (based on ProjectResource)
type ProjectSettings ¶
type ProjectStats ¶
type ProjectStatus ¶
type SprintCompact ¶
type SprintResponse ¶
type SprintResponse struct {
ID int `json:"id"`
Code string `json:"code"`
Slug string `json:"slug"`
Title string `json:"title"`
Color string `json:"color"`
Description string `json:"description"`
Duration int `json:"duration"`
Timebox SprintTimebox `json:"timebox"`
Stats SprintStats `json:"stats"`
Status SprintStatus `json:"status"`
Project *ProjectCompact `json:"project"`
Company *CompanyCompact `json:"company"`
CreatedAt *DateResponse `json:"created_at"`
}
SprintResponse represents a sprint from the API (based on SprintResource)
type SprintStats ¶
type SprintStatus ¶
type SprintTimebox ¶
type SprintTimebox struct {
Start *DateResponse `json:"start"`
Finish *DateResponse `json:"finish"`
}
type TaskResponse ¶
type TaskResponse struct {
UUID string `json:"uuid"`
Code string `json:"code"`
Slug string `json:"slug"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
Workflow *WorkflowResponse `json:"workflow"`
Users []UserResponse `json:"users"`
Settings TaskSettings `json:"settings"`
Stats TaskStats `json:"stats"`
Project *ProjectCompact `json:"project"`
Company *CompanyCompact `json:"company"`
Sprint *SprintCompact `json:"sprint"`
CreatedAt *DateResponse `json:"created_at"`
DueDate *DateResponse `json:"due_date"`
}
TaskResponse represents a task from the API (based on BoardTaskResource)
type TaskSettings ¶
type TimeTrackingResponse ¶
type TimeTrackingResponse struct {
Comment string `json:"comment"`
Time TimeTrackingTime `json:"time"`
Task *TaskResponse `json:"task"`
User *UserResponse `json:"user"`
Billed bool `json:"billed"`
IsBillable bool `json:"is_billable"`
}
TimeTrackingResponse represents a time tracking entry
type TimeTrackingTime ¶
type TimeTrackingTime struct {
ID int `json:"id"`
Start *DateResponse `json:"start"`
End *DateResponse `json:"end"`
Total string `json:"total"`
DurationMinutes int `json:"duration_minutes"`
}
type UserResponse ¶
type UserResponse struct {
UUID string `json:"uuid"`
Username string `json:"username"`
Name string `json:"name"`
Email string `json:"email"`
Photo *string `json:"photo"`
}
UserResponse represents a user from the API