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 CleanupWarning(err error) error
- func GenerateSuffix() string
- func IsCleanupWarning(err error) bool
- func ReportCleanupFailure(parentT *testing.T, prefix string, result *Result, err error)
- func ResolveBinaryPath(req Request) (string, error)
- func ResultHasRetryableError(result *Result) bool
- func SkipWithoutUserToken(t *testing.T)
- func WaitForCondition(ctx context.Context, opts WaitOptions, condition func() (bool, error)) error
- type Request
- type Result
- type RetryOptions
- type WaitOptions
Constants ¶
const ( // CleanupTimeout is the outer teardown budget. Keep it above any // per-resource wait so cleanup command retries still have room to run. CleanupTimeout = 60 * 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 CleanupWarning ¶ added in v1.0.67
CleanupWarning marks a cleanup verification issue as non-fatal after the destructive cleanup command itself has already succeeded.
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 IsCleanupWarning ¶ added in v1.0.67
IsCleanupWarning reports whether err should be logged without failing the parent test.
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 ResultHasRetryableError ¶ added in v1.0.67
ResultHasRetryableError reports whether lark-cli returned a structured service error with error.retryable=true in either output stream.
func SkipWithoutUserToken ¶ added in v1.0.14
func WaitForCondition ¶ added in v1.0.67
WaitForCondition polls condition until it returns true, an error, the context is canceled, or the configured timeout expires.
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
// Yes confirms high-risk-write commands. When true, the runner appends
// --yes so the framework-level confirmation gate passes. Setting it on a
// non-high-risk command will fail with "unknown flag: --yes".
Yes bool
}
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 RunCmd ¶
RunCmd executes lark-cli and captures stdout/stderr/exit code. Service errors that return {"error":{"retryable":true}} are retried with bounded exponential backoff so individual tests do not need to remember RunCmdWithRetry for normal transient server contention.
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.