Documentation
¶
Index ¶
- type Harness
- type InstallingUpdatePayload
- type LogPayload
- type Message
- func (m Message) GetInstallingUpdatePayload() (*InstallingUpdatePayload, bool)
- func (m Message) GetLogPayload() (*LogPayload, bool)
- func (m Message) GetProgressPayload() (*ProgressPayload, bool)
- func (m Message) GetUpdateFailedPayload() (*UpdateFailedPayload, bool)
- func (m Message) GetUpdateReadyPayload() (*UpdateReadyPayload, bool)
- type MessageType
- type MockBuild
- type MockBuildFile
- type MockServer
- func (ms *MockServer) Close()
- func (ms *MockServer) CreateMockArchive(appName string) []byte
- func (ms *MockServer) SetArchive(appName, version string, data []byte)
- func (ms *MockServer) SetBuildInfo(appName, version string, archiveSize int64)
- func (ms *MockServer) SetLatestVersion(appName, version string)
- func (ms *MockServer) URL() string
- type MultiverseSetup
- func (m *MultiverseSetup) BaseDir() string
- func (m *MultiverseSetup) CreateAppVersion(version string) string
- func (m *MultiverseSetup) CreateFullSetup(currentVersion string)
- func (m *MultiverseSetup) CreateWithReadyPending(currentVersion, readyVersion string)
- func (m *MultiverseSetup) ReadState() *MultiverseState
- func (m *MultiverseSetup) SetState(current, ready string)
- type MultiverseState
- type NoUpdateAvailablePayload
- type ProgressPayload
- type ReadyToRelaunchPayload
- type Result
- type UpdateFailedPayload
- type UpdateReadyPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Harness ¶
type Harness struct {
// contains filtered or unexported fields
}
Harness manages the test environment for itch-setup
func (*Harness) Cleanup ¶
func (h *Harness) Cleanup()
Cleanup removes temporary files and stops the server
func (*Harness) Run ¶
Run executes itch-setup with the given arguments. Always injects --silent to avoid GTK initialization in tests.
func (*Harness) RunWithEnv ¶
RunWithEnv executes itch-setup with extra environment variables. Always injects --silent to avoid GTK initialization in tests.
func (*Harness) Server ¶
func (h *Harness) Server() *MockServer
Server returns the mock server for configuration
type InstallingUpdatePayload ¶
type InstallingUpdatePayload struct {
Version string `json:"version"`
}
InstallingUpdatePayload contains the version being installed
type LogPayload ¶
LogPayload contains log messages
type Message ¶
type Message struct {
Type MessageType `json:"type"`
Payload json.RawMessage `json:"payload"`
}
Message represents a parsed JSON message from itch-setup stdout
func ParseMessage ¶
ParseMessage parses a single line of JSON output
func ParseMessages ¶
ParseMessages extracts JSON messages from stdout
func (Message) GetInstallingUpdatePayload ¶
func (m Message) GetInstallingUpdatePayload() (*InstallingUpdatePayload, bool)
GetInstallingUpdatePayload extracts the payload for installing-update messages
func (Message) GetLogPayload ¶
func (m Message) GetLogPayload() (*LogPayload, bool)
GetLogPayload extracts the payload for log messages
func (Message) GetProgressPayload ¶
func (m Message) GetProgressPayload() (*ProgressPayload, bool)
GetProgressPayload extracts the payload for progress messages
func (Message) GetUpdateFailedPayload ¶
func (m Message) GetUpdateFailedPayload() (*UpdateFailedPayload, bool)
GetUpdateFailedPayload extracts the payload for update-failed messages
func (Message) GetUpdateReadyPayload ¶
func (m Message) GetUpdateReadyPayload() (*UpdateReadyPayload, bool)
GetUpdateReadyPayload extracts the payload for update-ready messages
type MessageType ¶
type MessageType string
MessageType represents the type of JSON message emitted by itch-setup
const ( TypeNoUpdateAvailable MessageType = "no-update-available" TypeInstallingUpdate MessageType = "installing-update" TypeProgress MessageType = "progress" TypeUpdateReady MessageType = "update-ready" TypeUpdateFailed MessageType = "update-failed" TypeReadyToRelaunch MessageType = "ready-to-relaunch" TypeLog MessageType = "log" )
type MockBuild ¶
type MockBuild struct {
Version string `json:"version"`
Files []MockBuildFile `json:"files"`
}
MockBuild represents build info returned by the /info endpoint
type MockBuildFile ¶
type MockBuildFile struct {
Type string `json:"type"`
SubType string `json:"subType"`
Size int64 `json:"size"`
}
MockBuildFile represents a file in the build
type MockServer ¶
type MockServer struct {
// contains filtered or unexported fields
}
MockServer simulates broth.itch.zone for testing
func NewMockServer ¶
func NewMockServer(t *testing.T) *MockServer
NewMockServer creates a new mock broth server
func (*MockServer) CreateMockArchive ¶
func (ms *MockServer) CreateMockArchive(appName string) []byte
CreateMockArchive creates a minimal zip archive with a mock executable
func (*MockServer) SetArchive ¶
func (ms *MockServer) SetArchive(appName, version string, data []byte)
SetArchive sets the archive data for a specific version
func (*MockServer) SetBuildInfo ¶
func (ms *MockServer) SetBuildInfo(appName, version string, archiveSize int64)
SetBuildInfo sets the build info for a specific version
func (*MockServer) SetLatestVersion ¶
func (ms *MockServer) SetLatestVersion(appName, version string)
SetLatestVersion sets the latest version for an app's channel
type MultiverseSetup ¶
type MultiverseSetup struct {
// contains filtered or unexported fields
}
MultiverseSetup helps create test directory structures
func NewMultiverseSetup ¶
func NewMultiverseSetup(t *testing.T, tempDir, appName string) *MultiverseSetup
NewMultiverseSetup creates a new multiverse setup helper
func (*MultiverseSetup) BaseDir ¶
func (m *MultiverseSetup) BaseDir() string
BaseDir returns the base directory path (e.g., ~/.itch)
func (*MultiverseSetup) CreateAppVersion ¶
func (m *MultiverseSetup) CreateAppVersion(version string) string
CreateAppVersion creates a mock app installation
func (*MultiverseSetup) CreateFullSetup ¶
func (m *MultiverseSetup) CreateFullSetup(currentVersion string)
CreateFullSetup creates a complete multiverse with current version installed
func (*MultiverseSetup) CreateWithReadyPending ¶
func (m *MultiverseSetup) CreateWithReadyPending(currentVersion, readyVersion string)
CreateWithReadyPending creates a multiverse with a pending ready version
func (*MultiverseSetup) ReadState ¶
func (m *MultiverseSetup) ReadState() *MultiverseState
ReadState reads the current state.json
func (*MultiverseSetup) SetState ¶
func (m *MultiverseSetup) SetState(current, ready string)
SetState writes the state.json file
type MultiverseState ¶
MultiverseState represents the state.json format
type NoUpdateAvailablePayload ¶
type NoUpdateAvailablePayload struct{}
NoUpdateAvailablePayload is empty
type ProgressPayload ¶
type ProgressPayload struct {
Progress float64 `json:"progress"`
BPS float64 `json:"bps"`
ETA float64 `json:"eta"`
}
ProgressPayload contains download/install progress
type Result ¶
Result holds the output from running itch-setup
func (*Result) GetAllMessagesOfType ¶
func (r *Result) GetAllMessagesOfType(t MessageType) []Message
GetAllMessagesOfType returns all messages of the given type
func (*Result) GetFirstMessageOfType ¶
func (r *Result) GetFirstMessageOfType(t MessageType) *Message
GetFirstMessageOfType returns the first message of the given type
func (*Result) HasMessageType ¶
func (r *Result) HasMessageType(t MessageType) bool
HasMessageType checks if the result contains a message of the given type
type UpdateFailedPayload ¶
type UpdateFailedPayload struct {
Message string `json:"message"`
}
UpdateFailedPayload contains the error message
type UpdateReadyPayload ¶
type UpdateReadyPayload struct {
Version string `json:"version"`
}
UpdateReadyPayload contains the version that's ready