mirror of
https://github.com/larksuite/cli.git
synced 2026-07-08 10:08:02 +08:00
Compare commits
1 Commits
feat/sidec
...
fix/shortc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b88039eeca |
@@ -127,8 +127,8 @@ func (f *Factory) CheckIdentity(as core.Identity, supported []string) error {
|
|||||||
list := strings.Join(supported, ", ")
|
list := strings.Join(supported, ", ")
|
||||||
if f.IdentityAutoDetected {
|
if f.IdentityAutoDetected {
|
||||||
return output.ErrValidation(
|
return output.ErrValidation(
|
||||||
"resolved identity %q (via auto-detect or default-as) is not supported, this command only supports: %s\nhint: use --as %s",
|
"this command requires %s identity, but no user login was found (auto-detected as %s)\nhint: run `lark-cli auth login` first, then retry",
|
||||||
as, list, supported[0])
|
list, as)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("--as %s is not supported, this command only supports: %s", as, list)
|
return fmt.Errorf("--as %s is not supported, this command only supports: %s", as, list)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,15 +174,15 @@ func TestCheckIdentity_Unsupported_AutoDetected(t *testing.T) {
|
|||||||
f, _, _, _ := TestFactory(t, &core.CliConfig{AppID: "a", AppSecret: "s"})
|
f, _, _, _ := TestFactory(t, &core.CliConfig{AppID: "a", AppSecret: "s"})
|
||||||
f.IdentityAutoDetected = true
|
f.IdentityAutoDetected = true
|
||||||
|
|
||||||
err := f.CheckIdentity(core.AsUser, []string{"bot"})
|
err := f.CheckIdentity(core.AsBot, []string{"user"})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected error")
|
t.Fatal("expected error")
|
||||||
}
|
}
|
||||||
if !strings.Contains(err.Error(), "resolved identity") {
|
if !strings.Contains(err.Error(), "requires user identity") {
|
||||||
t.Errorf("expected 'resolved identity' in error, got: %v", err)
|
t.Errorf("expected 'requires user identity' in error, got: %v", err)
|
||||||
}
|
}
|
||||||
if !strings.Contains(err.Error(), "hint: use --as bot") {
|
if !strings.Contains(err.Error(), "auth login") {
|
||||||
t.Errorf("expected hint in error, got: %v", err)
|
t.Errorf("expected 'auth login' hint in error, got: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user