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

Function newTestAPIClient

internal/client/client_test.go:52–69  ·  view source on GitHub ↗

newTestAPIClient creates an APIClient with a mock HTTP transport.

(t *testing.T, rt http.RoundTripper)

Source from the content-addressed store, hash-verified

50
51// newTestAPIClient creates an APIClient with a mock HTTP transport.
52func newTestAPIClient(t *testing.T, rt http.RoundTripper) (*APIClient, *bytes.Buffer) {
53 t.Helper()
54 errBuf := &bytes.Buffer{}
55 httpClient := &http.Client{Transport: rt}
56 sdk := lark.NewClient("test-app", "test-secret",
57 lark.WithEnableTokenCache(false),
58 lark.WithLogLevel(larkcore.LogLevelError),
59 lark.WithHttpClient(httpClient),
60 )
61 testCred := credential.NewCredentialProvider(nil, nil, &staticTokenResolver{}, nil)
62 cfg := &core.CliConfig{AppID: "test-app", AppSecret: "test-secret", Brand: core.BrandFeishu}
63 return &APIClient{
64 SDK: sdk,
65 ErrOut: errBuf,
66 Credential: testCred,
67 Config: cfg,
68 }, errBuf
69}
70
71func TestIsJSONContentType(t *testing.T) {
72 tests := []struct {

Calls 1

NewCredentialProviderFunction · 0.92

Tested by

no test coverage detected