testutil

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockHTTPServer

type MockHTTPServer struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

MockHTTPServer is a test HTTP server that serves files with deterministic content

func NewMockHTTPServer

func NewMockHTTPServer() *MockHTTPServer

NewMockHTTPServer creates a new mock HTTP server

func (*MockHTTPServer) AddFile

func (ms *MockHTTPServer) AddFile(path, content string) string

AddFile adds a file with deterministic content to the mock server Returns the sha256 checksum of the content

func (*MockHTTPServer) AddFileWithHeaders

func (ms *MockHTTPServer) AddFileWithHeaders(path, content string, headers map[string]string) string

AddFileWithHeaders adds a file with deterministic content and custom HTTP headers Returns the sha256 checksum of the content

func (*MockHTTPServer) Close

func (ms *MockHTTPServer) Close()

Close shuts down the mock HTTP server

func (*MockHTTPServer) HasRequest

func (ms *MockHTTPServer) HasRequest(pattern string) bool

HasRequest checks if a request matching the pattern was made

func (*MockHTTPServer) Requests

func (ms *MockHTTPServer) Requests() []string

Requests returns all requests made to the server since last reset

func (*MockHTTPServer) ResetRequests

func (ms *MockHTTPServer) ResetRequests()

ResetRequests clears the tracked requests

func (*MockHTTPServer) URL

func (ms *MockHTTPServer) URL() string

URL returns the base URL of the mock HTTP server

type MockRegistry

type MockRegistry struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

MockRegistry is a test registry server that serves images with deterministic digests

func NewMockRegistry

func NewMockRegistry() *MockRegistry

NewMockRegistry creates a new mock registry server

func (*MockRegistry) AddEmptyImage

func (mr *MockRegistry) AddEmptyImage(repo, tag string) (string, error)

AddEmptyImage adds an empty (scratch-based) image to the mock registry

func (*MockRegistry) AddImage

func (mr *MockRegistry) AddImage(repo, tag string, imageID int64) (string, error)

AddImage adds an image to the mock registry with a deterministic digest The imageID is used to generate unique but deterministic content

func (*MockRegistry) AddImageWithConfig

func (mr *MockRegistry) AddImageWithConfig(repo, tag string, config v1.Config) (string, error)

AddImageWithConfig adds an image with specific config to make digests deterministic

func (*MockRegistry) Close

func (mr *MockRegistry) Close()

Close shuts down the mock registry server

func (*MockRegistry) HasRequest

func (mr *MockRegistry) HasRequest(pattern string) bool

HasRequest checks if a request matching the pattern was made Pattern can be a substring match (e.g., "GET /v2/library/alpine/manifests")

func (*MockRegistry) Host

func (mr *MockRegistry) Host() string

Host returns the host:port of the mock registry

func (*MockRegistry) RequestCount

func (mr *MockRegistry) RequestCount(pattern string) int

RequestCount returns the number of requests matching the pattern

func (*MockRegistry) Requests

func (mr *MockRegistry) Requests() []string

Requests returns all requests made to the registry since last reset

func (*MockRegistry) ResetRequests

func (mr *MockRegistry) ResetRequests()

ResetRequests clears the tracked requests

func (*MockRegistry) WriteRegistriesConf

func (mr *MockRegistry) WriteRegistriesConf(dir string, registries ...string) (string, error)

WriteRegistriesConf creates a registries.conf file that redirects the specified registries to the mock registry server. Returns the path to the created file.

Jump to

Keyboard shortcuts

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