mirror of
https://github.com/larksuite/cli.git
synced 2026-08-03 08:32:46 +08:00
fix(shortcuts): stop printing the import alias as the brand word
The internal/core split renamed the brand package and aliased the import as brandpkg, and the sweep that rewrote `brand.` also rewrote the word ending three sentences. One of them is user-visible: `apps --help` on Lark read "The "apps" feature is not yet supported on the lark brandpkg." The error path a few lines above was spelled without the trailing period and escaped the sweep, so the two surfaces disagreed. The brand-guard tests only exercised RunE, which --help bypasses, so nothing covered the sentence. Pin it whole: a substring check would still pass on a mangled tail. The other two are comments in internal/auth.
This commit is contained in:
@@ -94,7 +94,7 @@ func TestRequestAppRegistration_UsesFeishuBootstrapAndConfiguredVerificationBran
|
||||
// Full Lark routing contract: Lark selects the Lark verification page, while
|
||||
// registration bootstraps on Feishu and switches only after the tenant signal.
|
||||
// The Lark credential response omits user_info, so the effective domain must
|
||||
// still determine the saved brandpkg.
|
||||
// still determine the saved brand.
|
||||
func TestRegisterAppWithDiscovery_LarkFlowUsesProtocolBootstrap(t *testing.T) {
|
||||
var calls []string
|
||||
client := &http.Client{Transport: roundTripFunc(func(r *http.Request) (*http.Response, error) {
|
||||
|
||||
@@ -51,7 +51,7 @@ type OAuthEndpoints struct {
|
||||
Token string
|
||||
}
|
||||
|
||||
// ResolveOAuthEndpoints resolves OAuth endpoint URLs based on brandpkg.
|
||||
// ResolveOAuthEndpoints resolves OAuth endpoint URLs based on brand.
|
||||
func ResolveOAuthEndpoints(brand brandpkg.Brand) OAuthEndpoints {
|
||||
ep := brandpkg.ResolveEndpoints(brand)
|
||||
return OAuthEndpoints{
|
||||
|
||||
@@ -204,7 +204,7 @@ func installBrandRestrictionGuard(svc *cobra.Command, service string, brand bran
|
||||
walk(svc)
|
||||
|
||||
// --help bypasses RunE, so surface the restriction in Long too.
|
||||
svc.Long = fmt.Sprintf("The %q feature is not yet supported on the %s brandpkg.", service, brand)
|
||||
svc.Long = fmt.Sprintf("The %q feature is not yet supported on the %s brand.", service, brand)
|
||||
}
|
||||
|
||||
// Sheets backward-compatibility grouping.
|
||||
|
||||
@@ -104,6 +104,26 @@ func TestBrandGuard_AppsExecutableOnFeishu(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestBrandGuard_HelpTextNamesTheBrand covers the surface the tests above cannot
|
||||
// reach: --help bypasses RunE, so the restriction is repeated in Long. A
|
||||
// package-rename sweep turned the sentence's trailing "brand." into the import
|
||||
// alias, and `apps --help` on Lark read "the lark brandpkg." until this pinned
|
||||
// the wording. Asserting the whole sentence keeps a substring check from passing
|
||||
// on a mangled tail.
|
||||
func TestBrandGuard_HelpTextNamesTheBrand(t *testing.T) {
|
||||
program := &cobra.Command{Use: "root"}
|
||||
RegisterShortcuts(program, newFactoryWithBrand(brandpkg.Lark))
|
||||
|
||||
apps := findChild(program, "apps")
|
||||
if apps == nil {
|
||||
t.Fatal("apps should be registered")
|
||||
}
|
||||
want := `The "apps" feature is not yet supported on the lark brand.`
|
||||
if apps.Long != want {
|
||||
t.Errorf("apps help text = %q, want %q", apps.Long, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBrandGuard_DispatchHitsStubViaCobra(t *testing.T) {
|
||||
program := &cobra.Command{Use: "root"}
|
||||
RegisterShortcuts(program, newFactoryWithBrand(brandpkg.Lark))
|
||||
|
||||
Reference in New Issue
Block a user