harness

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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 New

func New(t *testing.T) *Harness

New creates a new test harness

func (*Harness) Cleanup

func (h *Harness) Cleanup()

Cleanup removes temporary files and stops the server

func (*Harness) Run

func (h *Harness) Run(args ...string) *Result

Run executes itch-setup with the given arguments. Always injects --silent to avoid GTK initialization in tests.

func (*Harness) RunWithEnv

func (h *Harness) RunWithEnv(extraEnv map[string]string, args ...string) *Result

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

func (*Harness) ServerURL

func (h *Harness) ServerURL() string

ServerURL returns the mock server URL

func (*Harness) TempDir

func (h *Harness) TempDir() string

TempDir returns the temporary directory for this test

type InstallingUpdatePayload

type InstallingUpdatePayload struct {
	Version string `json:"version"`
}

InstallingUpdatePayload contains the version being installed

type LogPayload

type LogPayload struct {
	Level   string `json:"level"`
	Message string `json:"message"`
}

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

func ParseMessage(line string) (Message, bool)

ParseMessage parses a single line of JSON output

func ParseMessages

func ParseMessages(stdout string) []Message

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) Close

func (ms *MockServer) Close()

Close shuts down the mock 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

func (*MockServer) URL

func (ms *MockServer) URL() string

URL returns the mock server's URL

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

type MultiverseState struct {
	Current string `json:"current"`
	Ready   string `json:"ready"`
}

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 ReadyToRelaunchPayload

type ReadyToRelaunchPayload struct{}

ReadyToRelaunchPayload is empty

type Result

type Result struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Messages []Message
}

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

Jump to

Keyboard shortcuts

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