clie2e

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 13 Imported by: 0

README

CLI E2E Tests

This directory contains end-to-end tests for lark-cli.

The purpose of this module is to verify real CLI workflows from a user-facing perspective: run the compiled binary, execute commands end to end, and catch regressions that are not obvious from unit tests alone.

What Is Here

  • core.go, core_test.go: the shared E2E test harness and its own tests
  • demo/: reference testcase(s)
  • cli-e2e-testcase-writer/: the local skill for adding or updating testcase files in this module

For Contributors

When writing or updating testcases under tests/cli_e2e, install and use this skill first:

npx skills add ./tests/cli_e2e/cli-e2e-testcase-writer

Then follow tests/cli_e2e/cli-e2e-testcase-writer/SKILL.md.

Example prompt:

Use $cli-e2e-testcase-writer to write lark-cli xxx domain related testcases.
Put them under tests/cli_e2e/xxx.

Run

make build
go test ./tests/cli_e2e/... -count=1

Documentation

Overview

Package clie2e contains end-to-end tests for lark-cli.

Index

Constants

View Source
const EnvBinaryPath = "LARK_CLI_BIN"

Variables

This section is empty.

Functions

func BuildArgs

func BuildArgs(req Request) ([]string, error)

BuildArgs converts a request into CLI arguments.

func ResolveBinaryPath

func ResolveBinaryPath(req Request) (string, error)

ResolveBinaryPath finds the CLI binary path using request, env, then PATH.

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
	// 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
}

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

func RunCmd(ctx context.Context, req Request) (*Result, error)

RunCmd executes lark-cli and captures stdout/stderr/exit code.

func (*Result) AssertExitCode

func (r *Result) AssertExitCode(t *testing.T, code int)

AssertExitCode asserts the exit code.

func (*Result) AssertStdoutStatus

func (r *Result) AssertStdoutStatus(t *testing.T, expected any)

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

func (r *Result) StderrJSON(t *testing.T) any

StderrJSON decodes stderr as JSON.

func (*Result) StdoutJSON

func (r *Result) StdoutJSON(t *testing.T) any

StdoutJSON decodes stdout as JSON.

Jump to

Keyboard shortcuts

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