用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ravi-hq/cli --skill gen-test命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when working with the Ravi CLI — identity, inbox, passwords, secrets, email, SMS, calls, and feedback commands
Use when testing CLI changes against the local backend before committing. Covers building with local endpoint, authenticating, and driving every command group with verification.
Use when releasing a new Ravi CLI version — version bump, tagging, and verification
正在显示 SKILL.md
| name | gen-test |
| description | Use when generating a Go test file for a module following Ravi CLI test conventions |
Generate a Go test file for a specified module, following all Ravi CLI test conventions.
The user should specify which module to generate tests for (e.g., "gen-test internal/api/secrets.go" or "gen-test pkg/cli/passwords.go").
<module>_test.go in the same package directory_test suffix — tests are white-box)[]struct{ name string; ... } with t.Run(tt.name, ...)t.Helper() as the first linewithTempHome(t) for any test that touches config.LoadAuth(), config.SaveAuth(), or os.UserHomeDir()httptest.NewServer() + newTestClient(server.URL) or clientFromAuth(server.URL, auth)testKeyPair(t) (PIN "123456", zero salt) for deterministic keypairt.Fatalf for setup failures, t.Errorf for assertion failuresdefer cleanup() or defer server.Close() immediately after creationinternal/api/ packagewithTempHome(t) // Temp HOME dir, returns (tmpDir, cleanup)
withAPIBaseURL(t, url) // Temp API URL override, returns cleanup
setupTestAuth(t, auth) // Save auth config to temp home
newTestClient(serverURL) // Client with test-token, no disk config
clientFromAuth(serverURL, auth) // Client with specific auth config
internal/crypto/ packagetestKeyPair(t) // Deterministic keypair (PIN "123456", zero salt)
testEncrypt(t, plaintext, kp) // Encrypt with SealAnonymous
pkg/cli/ packagewithTempHome(t) // Same pattern as api package (redefined)
*_test.go files in the same directory to match local patternswithTempHome, etc.)withTempHome(t) + defer cleanup() for config-dependent testshttptest.NewServer mocks for API client testspackage api
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestMyFunction(t *testing.T) {
tests := []struct {
name string
input string
want string
wantErr bool
}{
{"valid input", "hello", "HELLO", false},
{"empty string", "", "", false},
{"special chars", "e2e::data", "E2E::DATA", false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := MyFunction(tt.input)
if (err != nil) != tt.wantErr {
t.Fatalf("MyFunction(%q) error = %v, wantErr %v", tt.input, err, tt.wantErr)
}
if got != tt.want {
t.Errorf("MyFunction(%q) = %q, want %q", tt.input, got, tt.want)
}
})
}
}
func TestMyAPIMethod(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write([]byte())
}))
server.Close()
client := newTestClient(server.URL)
}