newTestAPIClient creates an APIClient with a mock HTTP transport.
(t *testing.T, rt http.RoundTripper)
| 50 | |
| 51 | // newTestAPIClient creates an APIClient with a mock HTTP transport. |
| 52 | func 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 | |
| 71 | func TestIsJSONContentType(t *testing.T) { |
| 72 | tests := []struct { |
no test coverage detected