MCPcopy
hub / github.com/larksuite/cli / TestBuild_ExternalAPI

Function TestBuild_ExternalAPI

cmd/build_api_test.go:27–50  ·  view source on GitHub ↗

TestBuild_ExternalAPI asserts the library surface that external consumers (e.g. cli-server) depend on: Build composes a root command from an InvocationContext plus BuildOptions (WithIO, WithKeychain, HideProfile), and SetDefaultFS swaps the global VFS. This test is the contract guard.

(t *testing.T)

Source from the content-addressed store, hash-verified

25// InvocationContext plus BuildOptions (WithIO, WithKeychain, HideProfile),
26// and SetDefaultFS swaps the global VFS. This test is the contract guard.
27func TestBuild_ExternalAPI(t *testing.T) {
28 // Exercise SetDefaultFS both directions. Passing nil restores the OS FS.
29 SetDefaultFS(vfs.OsFs{})
30 SetDefaultFS(nil)
31
32 var in, out, errOut bytes.Buffer
33 rootCmd := Build(
34 context.Background(),
35 cmdutil.InvocationContext{},
36 WithIO(&in, &out, &errOut),
37 WithKeychain(noopKeychain{}),
38 HideProfile(true),
39 )
40
41 if rootCmd == nil {
42 t.Fatal("Build returned nil root command")
43 }
44 if rootCmd.Use != "lark-cli" {
45 t.Errorf("rootCmd.Use = %q, want %q", rootCmd.Use, "lark-cli")
46 }
47 if len(rootCmd.Commands()) == 0 {
48 t.Error("Build produced a root command with no subcommands")
49 }
50}
51
52// TestBuild_NoOptions guards against regression of the nil-streams panic:
53// calling Build without WithIO must fall back to SystemIO rather than

Callers

nothing calls this directly

Calls 6

SetDefaultFSFunction · 0.85
WithIOFunction · 0.85
WithKeychainFunction · 0.85
HideProfileFunction · 0.85
BuildFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected