65 lines
1.4 KiB
Markdown
65 lines
1.4 KiB
Markdown
# Inbox `init` Test Plan
|
|
|
|
## Scope
|
|
|
|
This document covers the externally visible behavior of `inbox init`.
|
|
|
|
Shared conventions live in [../_shared/README.md](../_shared/README.md).
|
|
|
|
## case: init-creates-schema-on-empty-db
|
|
|
|
### 用例意义
|
|
|
|
验证在空数据库路径上执行 `init` 会创建可用的 inbox schema,并返回稳定的初始化响应。
|
|
|
|
### 前置条件
|
|
|
|
- 选择一个尚不存在的数据库路径 `TMPDIR/coord.db`
|
|
|
|
### 输入
|
|
|
|
```bash
|
|
inbox --db TMPDIR/coord.db --json init
|
|
```
|
|
|
|
### 预期输出
|
|
|
|
- 命令退出码为 `0`
|
|
- 返回 `ok=true`
|
|
- `command` 为 `init`
|
|
- `data.db_path` 等于传入路径
|
|
- `data.status` 为 `initialized`
|
|
|
|
### 断言结论
|
|
|
|
- `init` 在空路径上可以直接完成 schema 初始化
|
|
- 初始化结果足以让后续 `send`、`fetch` 等命令继续使用同一数据库
|
|
|
|
## case: init-is-idempotent-on-existing-db
|
|
|
|
### 用例意义
|
|
|
|
验证 `init` 可以对已初始化过的数据库重复执行,而不会报错或破坏已有 schema。
|
|
|
|
### 前置条件
|
|
|
|
- `TMPDIR/coord.db` 已经执行过一次 `inbox --db TMPDIR/coord.db --json init`
|
|
|
|
### 输入
|
|
|
|
```bash
|
|
inbox --db TMPDIR/coord.db --json init
|
|
inbox --db TMPDIR/coord.db --json init
|
|
```
|
|
|
|
### 预期输出
|
|
|
|
- 两次命令都退出码为 `0`
|
|
- 两次响应都返回 `data.status == "initialized"`
|
|
- 两次响应都返回相同的 `data.db_path`
|
|
|
|
### 断言结论
|
|
|
|
- `init` 是幂等操作
|
|
- 对已存在 schema 的重复初始化不应引入额外迁移失败或状态漂移
|