testkit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SecretKey = "sk-test-SECRET-0123456789"

Variables

This section is empty.

Functions

func CLIApp

func CLIApp(t *testing.T) (*app.App, *FakeKeyring, *FakeJev)

cliApp is newApp plus a fake keychain and jev client.

func MustRunWith

func MustRunWith(t *testing.T, a *app.App, commands func() []*cobra.Command, stdin string, want int, args ...string) (stdout, stderr string)

func NewApp

func NewApp(t *testing.T) *app.App

func NoSecret

func NoSecret(t *testing.T, what string, outs ...string)

func ReadFile

func ReadFile(t *testing.T, path string) string

func RunWith

func RunWith(a *app.App, commands func() []*cobra.Command, stdin string, args ...string) (code int, stdout, stderr string)

run executes one command with fresh buffers. runWith executes one command with fresh buffers. commands builds the top-level commands after the buffers are installed.

func WriteFile

func WriteFile(t *testing.T, path, content string)

Types

type FakeJev

type FakeJev struct {
	Calls int
	Keys  []string
	Err   error
	Resp  *jev.Response
	Req   jev.Request
}

fakeJev records calls and returns a canned result.

func (*FakeJev) Ask

func (f *FakeJev) Ask(_ context.Context, req jev.Request) (*jev.Response, error)

type FakeKeyring

type FakeKeyring struct {
	Items       map[string]string
	Unavailable bool
}

FakeKeyring is an in-memory keychain.

func (*FakeKeyring) Delete

func (k *FakeKeyring) Delete(service, account string) error

func (*FakeKeyring) Get

func (k *FakeKeyring) Get(service, account string) (string, error)

func (*FakeKeyring) Set

func (k *FakeKeyring) Set(service, account, secret string) error

Jump to

Keyboard shortcuts

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