Help us shape the future of Go! Take the 2026 Go Developer Survey

apitest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package apitest 是 CLI/SDK 侧集成测试的进程内服务装配夹具:真实 internal/api 服务实现 + 独立临时目录 sqlite + 生产同构拦截链(auth)的 bufconn gRPC server。它存在的理由(T2.18):cmd/fleetly 测试需要「真实 api 面」做 golden 快照与退出码断言,但 fence 禁止 cmd/fleetly 触及 internal/state 等装配依赖——装配知识集中在本包,测试侧只拿连接与 token。

注意:本包是测试支持设施,不是产品代码;随服务面扩展同步登记注册。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

type Env struct {
	Conn       *grpc.ClientConn
	AdminToken string
	Store      *state.Store
	Dir        string
	// contains filtered or unexported fields
}

Env 是一次测试环境:连接、admin token 与底层 store(夹具播种用——仅 测试代码经它写行,被测 CLI 只走 gRPC 面)。

func Start

func Start(t *testing.T) *Env

Start 起一个完整服务面(除 ingress.Manager——nil 端口形态,入口面如实 报告不可用)并返回连接与 admin token;生命周期挂 t.Cleanup。

func (*Env) AppendEvent

func (e *Env) AppendEvent(t *testing.T, name, subject, payload string) int64

AppendEvent 播种一条注册表内事件(events watch 夹具)。

func (*Env) CreateApp

func (e *Env) CreateApp(t *testing.T, name string) state.App

CreateApp 播种一个应用行(读面测试的既有应用夹具;幂等——已存在时 返回既有行)。

func (*Env) DialOptions

func (e *Env) DialOptions() []grpc.DialOption

DialOptions 返回指向进程内 server 的拨号选项(CLI 测试经 extraDialOptions 注入——被测面与生产同路径走 fleetly.NewClient)。

func (*Env) SeedBackup

func (e *Env) SeedBackup(t *testing.T, kind, verify, errMsg string) state.StateBackup

SeedBackup 播种一条状态备份台账行(backups list 夹具;ID 按类别区分、 时间取按 kind 长度偏移的固定纪元——台账按 created_at DESC 排序,同刻 并列会造成顺序抖动,确定偏移使列表顺序稳定)。

func (*Env) SeedBuild

func (e *Env) SeedBuild(t *testing.T, appName, service string) string

SeedBuild 播种一条 queued 构建行(builds list 夹具)。

func (*Env) SeedDomain

func (e *Env) SeedDomain(t *testing.T, appName, service, domain, port string)

SeedDomain 播种一条域名台账行(domains list 夹具)。

func (*Env) SeedNode

func (e *Env) SeedNode(t *testing.T)

SeedNode 播种一条节点观测缓存行(nodes list 夹具)。

func (*Env) SeedPlacement

func (e *Env) SeedPlacement(t *testing.T, appName string) string

SeedPlacement 播种已绑定放置 + 已登记命名卷(placement show 夹具)。 应用以固定 ID 播种——卷名 `fleetly-<app>-<key>-<appid8>` 含 app ID 前 8 位,固定 ID 使 golden 快照确定。

func (*Env) SeedRevisionFromYAML

func (e *Env) SeedRevisionFromYAML(t *testing.T, appName, yamlText string) string

SeedRevisionFromYAML 经 compose.Load 解析夹具并固化一条成功版本快照 (ComposeNormalized = canonical JSON——与引擎 succeedDeployment 同形态), 返回 revision ID。

Jump to

Keyboard shortcuts

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