Documentation
¶
Overview ¶
Package clie2e contains end-to-end tests for lark-cli.
Index ¶
- Constants
- func BuildArgs(req Request) ([]string, error)
- func CleanupContext() (context.Context, context.CancelFunc)
- func GenerateSuffix() string
- func ReportCleanupFailure(parentT *testing.T, prefix string, result *Result, err error)
- func ResolveBinaryPath(req Request) (string, error)
- func SkipWithoutUserToken(t *testing.T)
- type Request
- type Result
- type RetryOptions
Constants ¶
const CleanupTimeout = 30 * time.Second
const EnvBinaryPath = "LARK_CLI_BIN"
Variables ¶
This section is empty.
Functions ¶
func CleanupContext ¶ added in v1.0.14
func CleanupContext() (context.Context, context.CancelFunc)
CleanupContext returns a bounded context for teardown operations so cleanup cannot outlive the test indefinitely when the remote API stalls.
func GenerateSuffix ¶ added in v1.0.10
func GenerateSuffix() string
GenerateSuffix returns a high-entropy UTC timestamp suffix suitable for remote test resource names.
func ReportCleanupFailure ¶ added in v1.0.14
ReportCleanupFailure emits a uniform cleanup error with command output.
func ResolveBinaryPath ¶
ResolveBinaryPath finds the CLI binary path using request, env, then PATH.
func SkipWithoutUserToken ¶ added in v1.0.14
Types ¶
type Request ¶
type Request struct {
// Args are required and exclude the lark-cli binary name.
Args []string
// Params is optional and becomes --params '<json>' when non-nil.
Params any
// Data is optional and becomes --data '<json>' when non-nil.
Data any
// Stdin is optional and becomes the child process stdin when non-nil.
// Use an empty slice to exercise empty-stdin behavior explicitly.
Stdin []byte
// BinaryPath is optional. Empty means: LARK_CLI_BIN, project-root ./lark-cli, then PATH.
BinaryPath string
// DefaultAs is optional and becomes --as <value> when non-empty.
DefaultAs string
// Format is optional and becomes --format <format> when non-empty.
Format string
// WorkDir is optional and becomes the child process working directory when non-empty.
WorkDir string
// Env adds or overrides environment variables for this one child process only.
Env map[string]string
}
Request describes one lark-cli invocation.
type Result ¶
type Result struct {
BinaryPath string
Args []string
ExitCode int
Stdout string
Stderr string
RunErr error
}
Result captures process execution output.
func RunCmdWithRetry ¶ added in v1.0.10
RunCmdWithRetry reruns a command when the result matches the configured retry condition.
func (*Result) AssertExitCode ¶
AssertExitCode asserts the exit code.
func (*Result) AssertStdoutStatus ¶
AssertStdoutStatus asserts stdout JSON status using either {"ok": ...} or {"code": ...}. This intentionally keeps one shared assertion entrypoint for CLI E2E call sites, so tests can stay uniform across shortcut-style {"ok": ...} responses and service-style {"code": ...} responses without branching on response shape.
func (*Result) StderrJSON ¶
StderrJSON decodes stderr as JSON.