From 73f8b208edf29c38ca7a4dbcdfee3380b3def879 Mon Sep 17 00:00:00 2001 From: luozhixiong Date: Fri, 29 May 2026 12:57:07 +0800 Subject: [PATCH] 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. --- cmd/config/bind_test.go | 2 ++ cmd/config/config_test.go | 14 ++++++++++++++ cmd/profile/profile_test.go | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/cmd/config/bind_test.go b/cmd/config/bind_test.go index b645e3eb1..4c9e339ea 100644 --- a/cmd/config/bind_test.go +++ b/cmd/config/bind_test.go @@ -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 { diff --git a/cmd/config/config_test.go b/cmd/config/config_test.go index 632414cd7..a8658bcb2 100644 --- a/cmd/config/config_test.go +++ b/cmd/config/config_test.go @@ -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 diff --git a/cmd/profile/profile_test.go b/cmd/profile/profile_test.go index 3cd724720..fe4fc85b9 100644 --- a/cmd/profile/profile_test.go +++ b/cmd/profile/profile_test.go @@ -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) {