測試改斷言具體結束碼數值,對照 README 規格(#10)
cli_test、dailyops_commands_test、login_test、exitcode_test 原以 int(ExitUsage)/int(ExitAPI)/int(ExitInternal) 常數互比,常數若再 與 README 脫鉤測試仍會綠。改為直接斷言 0/2/3(內部錯誤 1)。 常數本體已隨 #5(6951817)改為明確數值,未知命令實測回 2。
This commit is contained in:
@@ -53,8 +53,9 @@ func TestIssuesListRequiresRepo(t *testing.T) {
|
||||
t.Errorf("不應發出任何請求")
|
||||
})
|
||||
_, stderr, code := run("issues", "list")
|
||||
if code != int(ExitUsage) {
|
||||
t.Errorf("缺 --repo 應回 ExitUsage,得到 %d", code)
|
||||
// 對照 README「輸出與結束碼」:用法錯誤=2(#10)。
|
||||
if code != 2 {
|
||||
t.Errorf("缺 --repo 應回 2(README 用法錯誤),得到 %d", code)
|
||||
}
|
||||
if !strings.Contains(stderr, "--repo") {
|
||||
t.Errorf("錯誤訊息應提及 --repo,得到:%s", stderr)
|
||||
@@ -110,8 +111,9 @@ func TestWriteCommandsRequireYes(t *testing.T) {
|
||||
t.Errorf("%s:未帶 --yes 不得發出請求(%s %s)", tc.name, r.Method, r.URL.Path)
|
||||
})
|
||||
_, stderr, code := run(tc.args...)
|
||||
if code != int(ExitUsage) {
|
||||
t.Errorf("%s 未帶 --yes 應回 ExitUsage(2),得到 %d", tc.name, code)
|
||||
// 對照 README「輸出與結束碼」:用法錯誤=2(#10)。
|
||||
if code != 2 {
|
||||
t.Errorf("%s 未帶 --yes 應回 2(README 用法錯誤),得到 %d", tc.name, code)
|
||||
}
|
||||
if !strings.Contains(stderr, "--yes") {
|
||||
t.Errorf("%s 錯誤訊息應提及 --yes,得到:%s", tc.name, stderr)
|
||||
@@ -235,7 +237,8 @@ func TestAPIDirectPassthrough(t *testing.T) {
|
||||
}
|
||||
|
||||
_, stderr, code := run("api", "--method", "POST", "/version")
|
||||
if code != int(ExitUsage) || !strings.Contains(stderr, "--yes") {
|
||||
// 對照 README「輸出與結束碼」:用法錯誤=2(#10)。
|
||||
if code != 2 || !strings.Contains(stderr, "--yes") {
|
||||
t.Errorf("POST 未帶 --yes 應回 2 並提及 --yes,得到 %d:%s", code, stderr)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user