測試改斷言具體結束碼數值,對照 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:
@@ -51,8 +51,10 @@ func TestRunVersion(t *testing.T) {
|
||||
|
||||
func TestRunUnknownCommand(t *testing.T) {
|
||||
_, stderr, code := run("no-such-command")
|
||||
if code != int(ExitUsage) {
|
||||
t.Errorf("未知命令應回 ExitUsage(%d),得到 %d", int(ExitUsage), code)
|
||||
// 直接對照 README「輸出與結束碼」的數值(用法錯誤=2),
|
||||
// 不以常數互比,避免常數與規格再次脫鉤(#10)。
|
||||
if code != 2 {
|
||||
t.Errorf("未知命令應回 2(README 用法錯誤),得到 %d", code)
|
||||
}
|
||||
if !strings.Contains(stderr, "unknown command") {
|
||||
t.Errorf("未知命令應在 stderr 說明,得到:%q", stderr)
|
||||
|
||||
Reference in New Issue
Block a user