mirror of
https://github.com/larksuite/cli.git
synced 2026-07-18 09:36:35 +08:00
Port changes from feat/strict-mode-identity-filter_3 branch: - Add strict mode for identity filtering and configuration - Add profile management commands (add/list/remove/rename/use) - Add credential extension framework (registry, env provider) - Add VFS abstraction layer - Refactor factory default and client options - Update shortcuts to use new credential and validation patterns Change-Id: I8c104c6b147e1901d94aefcefe35a174932c742b Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import "testing"
|
|
|
|
func TestBootstrapInvocationContext_ProfileFlag(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"--profile", "target", "auth", "status"})
|
|
if err != nil {
|
|
t.Fatalf("BootstrapInvocationContext() error = %v", err)
|
|
}
|
|
if inv.Profile != "target" {
|
|
t.Fatalf("BootstrapInvocationContext() profile = %q, want %q", inv.Profile, "target")
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_ProfileEquals(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"auth", "status", "--profile=target"})
|
|
if err != nil {
|
|
t.Fatalf("BootstrapInvocationContext() error = %v", err)
|
|
}
|
|
if inv.Profile != "target" {
|
|
t.Fatalf("BootstrapInvocationContext() profile = %q, want %q", inv.Profile, "target")
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_IgnoresUnknownFlags(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"auth", "status", "--verify", "--profile", "target"})
|
|
if err != nil {
|
|
t.Fatalf("BootstrapInvocationContext() error = %v", err)
|
|
}
|
|
if inv.Profile != "target" {
|
|
t.Fatalf("BootstrapInvocationContext() profile = %q, want %q", inv.Profile, "target")
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_MissingProfileValue(t *testing.T) {
|
|
if _, err := BootstrapInvocationContext([]string{"auth", "status", "--profile"}); err == nil {
|
|
t.Fatal("BootstrapInvocationContext() error = nil, want non-nil")
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_HelpFlag(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"--help"})
|
|
if err != nil {
|
|
t.Fatalf("--help should not error, got: %v", err)
|
|
}
|
|
if inv.Profile != "" {
|
|
t.Fatalf("profile = %q, want empty", inv.Profile)
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_ShortHelp(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"-h"})
|
|
if err != nil {
|
|
t.Fatalf("-h should not error, got: %v", err)
|
|
}
|
|
if inv.Profile != "" {
|
|
t.Fatalf("profile = %q, want empty", inv.Profile)
|
|
}
|
|
}
|
|
|
|
func TestBootstrapInvocationContext_HelpWithProfile(t *testing.T) {
|
|
inv, err := BootstrapInvocationContext([]string{"--profile", "target", "--help"})
|
|
if err != nil {
|
|
t.Fatalf("--profile + --help should not error, got: %v", err)
|
|
}
|
|
if inv.Profile != "target" {
|
|
t.Fatalf("profile = %q, want %q", inv.Profile, "target")
|
|
}
|
|
}
|