test(config,profile): lock 'ko/ko_kr no longer accepted' contract

After the i18n catalog shrink, ko/ko_kr fall into the strict-reject
path of cmdutil.ParseLangFlag. Pin that with explicit test cases on
all three --lang entry points so future catalog edits can't silently
re-expand the supported set.
This commit is contained in:
luozhixiong
2026-05-29 12:57:07 +08:00
parent 645ae78b76
commit 73f8b208ed
3 changed files with 30 additions and 0 deletions

View File

@@ -152,6 +152,8 @@ func TestConfigBindRun_InvalidLang(t *testing.T) {
{"removed code ar", "ar"},
{"unknown xx", "xx"},
{"hyphen form zh-CN", "zh-CN"},
{"dropped short code ko", "ko"},
{"dropped locale ko_kr", "ko_kr"},
}
for _, tc := range cases {

View File

@@ -225,6 +225,8 @@ func TestConfigInitCmd_InvalidLang(t *testing.T) {
{"removed code ar", "ar"},
{"unknown xx", "xx"},
{"hyphen form zh-CN", "zh-CN"},
{"dropped short code ko", "ko"},
{"dropped locale ko_kr", "ko_kr"},
}
for _, tc := range cases {
@@ -509,6 +511,18 @@ func TestValidateInitLang(t *testing.T) {
}
}
})
t.Run("dropped short code ko errors", func(t *testing.T) {
opts := &ConfigInitOptions{Lang: "ko", langExplicit: true}
if err := validateInitLang(opts); err == nil {
t.Fatal("expected validation error for --lang ko, got nil")
}
})
t.Run("dropped locale ko_kr errors", func(t *testing.T) {
opts := &ConfigInitOptions{Lang: "ko_kr", langExplicit: true}
if err := validateInitLang(opts); err == nil {
t.Fatal("expected validation error for --lang ko_kr, got nil")
}
})
}
// TestPrintLangPreferenceConfirmation covers the confirmation helper: it prints

View File

@@ -100,6 +100,20 @@ func TestProfileAddRun_Lang(t *testing.T) {
t.Fatalf("expected ExitValidation, got %T: %v", err, err)
}
})
t.Run("dropped code ko errors", func(t *testing.T) {
setupProfileConfigDir(t)
f, _, _, _ := cmdutil.TestFactory(t, nil)
f.IOStreams.In = strings.NewReader("secret\n")
err := profileAddRun(f, "p", "app-p", true, "feishu", "ko", false)
if err == nil {
t.Fatal("expected validation error for --lang ko, got nil")
}
exitErr, ok := err.(*output.ExitError)
if !ok || exitErr.Code != output.ExitValidation {
t.Fatalf("expected ExitValidation, got %T: %v", err, err)
}
})
}
func TestProfileAddRun_UseAfterUpdatesCurrentAndPrevious(t *testing.T) {