Documentation
¶
Index ¶
- Variables
- func EnableDebugLogging()
- func WaitForFile(path string, timeout time.Duration) error
- type Buffer
- type CmdOpt
- type HTTPClient
- func (c *HTTPClient) BuildURL(urlPath string) string
- func (c *HTTPClient) DisableRedirects() *HTTPClient
- func (c *HTTPClient) Do(req *http.Request) *HTTPResponse
- func (c *HTTPClient) Get(urlPath string, opts ...func(*http.Request)) *HTTPResponse
- func (c *HTTPClient) Head(urlPath string, opts ...func(*http.Request)) *HTTPResponse
- func (c *HTTPClient) Post(urlPath string, body io.Reader, opts ...func(*http.Request)) *HTTPResponse
- func (c *HTTPClient) PostStr(urlpath, body string, opts ...func(*http.Request)) *HTTPResponse
- func (c *HTTPClient) WithHeader(k, v string) func(h *http.Request)
- type HTTPResponse
- type Harness
- func (h *Harness) Cleanup()
- func (h *Harness) Mkdirs(paths ...string)
- func (h *Harness) NewNode() *Node
- func (h *Harness) NewNodes(count int) Nodes
- func (h *Harness) Sh(expr string) RunResult
- func (h *Harness) TempFile() *os.File
- func (h *Harness) WriteFile(filename, contents string)
- func (h *Harness) WriteToTemp(contents string) string
- type Node
- func (n *Node) APIAddr() multiaddr.Multiaddr
- func (n *Node) APIClient() *HTTPClient
- func (n *Node) APIURL() string
- func (n *Node) Connect(other *Node) *Node
- func (n *Node) GatewayClient() *HTTPClient
- func (n *Node) GatewayURL() string
- func (n *Node) GetIPFSConfig(key string, val interface{})
- func (n *Node) IPFS(args ...string) RunResult
- func (n *Node) IPFSAdd(content io.Reader, args ...string) string
- func (n *Node) IPFSAddStr(content string, args ...string) string
- func (n *Node) IPFSCommands() []string
- func (n *Node) Init(ipfsArgs ...string) *Node
- func (n *Node) IsAlive() bool
- func (n *Node) PeerID() peer.ID
- func (n *Node) Peers() []multiaddr.Multiaddr
- func (n *Node) PipeStrToIPFS(s string, args ...string) RunResult
- func (n *Node) PipeToIPFS(reader io.Reader, args ...string) RunResult
- func (n *Node) ReadConfig() *config.Config
- func (n *Node) RunIPFS(args ...string) RunResult
- func (n *Node) RunPipeToIPFS(reader io.Reader, args ...string) RunResult
- func (n *Node) SetIPFSConfig(key string, val interface{}, flags ...string)
- func (n *Node) StartDaemon(ipfsArgs ...string) *Node
- func (n *Node) StopDaemon() *Node
- func (n *Node) SwarmAddrs() []multiaddr.Multiaddr
- func (n *Node) TryAPIAddr() (multiaddr.Multiaddr, error)
- func (n *Node) UpdateConfig(f func(cfg *config.Config))
- func (n *Node) WaitOnAPI() *Node
- func (n *Node) WriteConfig(c *config.Config)
- type Nodes
- type RunFunc
- type RunRequest
- type RunResult
- type Runner
Constants ¶
This section is empty.
Variables ¶
var RunFuncStart = (*exec.Cmd).Start
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a thread-safe byte buffer.
type HTTPClient ¶
type HTTPClient struct {
Client *http.Client
BaseURL string
Timeout time.Duration
TemplateData any
}
HTTPClient is an HTTP client with some conveniences for testing. URLs are constructed from a base URL. The response body is buffered into a string. Internal errors cause panics so that tests don't need to check errors. The paths are evaluated as Go templates for readable string interpolation.
func (*HTTPClient) BuildURL ¶
func (c *HTTPClient) BuildURL(urlPath string) string
BuildURL constructs a request URL from the given path by interpolating the string and then appending it to the base URL.
func (*HTTPClient) DisableRedirects ¶
func (c *HTTPClient) DisableRedirects() *HTTPClient
func (*HTTPClient) Do ¶
func (c *HTTPClient) Do(req *http.Request) *HTTPResponse
Do executes the request unchanged.
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(urlPath string, opts ...func(*http.Request)) *HTTPResponse
func (*HTTPClient) Head ¶
func (c *HTTPClient) Head(urlPath string, opts ...func(*http.Request)) *HTTPResponse
func (*HTTPClient) Post ¶
func (c *HTTPClient) Post(urlPath string, body io.Reader, opts ...func(*http.Request)) *HTTPResponse
func (*HTTPClient) PostStr ¶
func (c *HTTPClient) PostStr(urlpath, body string, opts ...func(*http.Request)) *HTTPResponse
func (*HTTPClient) WithHeader ¶
func (c *HTTPClient) WithHeader(k, v string) func(h *http.Request)
type HTTPResponse ¶
type Harness ¶
Harness tracks state for a test, such as temp dirs and IFPS nodes, and cleans them up after the test.
func (*Harness) WriteFile ¶
WriteFile writes a file given a filename and its contents. The filename must be a relative path, or this panics.
func (*Harness) WriteToTemp ¶
WriteToTemp writes the given contents to a guaranteed-unique temp file, returning its path.
type Node ¶
type Node struct {
ID int
Dir string
APIListenAddr multiaddr.Multiaddr
GatewayListenAddr multiaddr.Multiaddr
SwarmAddr multiaddr.Multiaddr
EnableMDNS bool
IPFSBin string
Runner *Runner
Daemon *RunResult
}
Node is a single Kubo node. Each node has its own config and can run its own Kubo daemon.
func (*Node) APIClient ¶
func (n *Node) APIClient() *HTTPClient
func (*Node) GatewayClient ¶
func (n *Node) GatewayClient() *HTTPClient
func (*Node) GatewayURL ¶
GatewayURL waits for the gateway file and then returns its contents or times out.
func (*Node) GetIPFSConfig ¶
func (*Node) IPFSCommands ¶
func (*Node) ReadConfig ¶
func (*Node) RunPipeToIPFS ¶
func (*Node) SetIPFSConfig ¶
func (*Node) StartDaemon ¶
func (*Node) StopDaemon ¶
func (*Node) SwarmAddrs ¶
func (*Node) UpdateConfig ¶
func (*Node) WriteConfig ¶
type Nodes ¶
type Nodes []*Node
Nodes is a collection of Kubo nodes along with operations on groups of nodes.
func (Nodes) StartDaemons ¶
func (Nodes) StopDaemons ¶
type RunRequest ¶
type Runner ¶
Runner is a process runner which can run subprocesses and aggregate output.
func (*Runner) AssertNoError ¶
func (*Runner) MustRun ¶
func (r *Runner) MustRun(req RunRequest) RunResult
MustRun runs the command and fails the test if the command fails.
func (*Runner) Run ¶
func (r *Runner) Run(req RunRequest) RunResult