mirror of
https://github.com/larksuite/cli.git
synced 2026-09-14 18:42:53 +08:00
83dfb068ad
Change-Id: I113d9cdb5403cec347efe4595415e34a18b7decf
45 lines
893 B
Go
45 lines
893 B
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmdutil
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestCachedHttpClientFunc_ReturnsSameInstance(t *testing.T) {
|
|
fn := cachedHttpClientFunc()
|
|
|
|
c1, err := fn()
|
|
if err != nil {
|
|
t.Fatalf("first call: %v", err)
|
|
}
|
|
if c1 == nil {
|
|
t.Fatal("first call returned nil")
|
|
}
|
|
|
|
c2, err := fn()
|
|
if err != nil {
|
|
t.Fatalf("second call: %v", err)
|
|
}
|
|
if c1 != c2 {
|
|
t.Error("expected same *http.Client instance on second call (cache hit)")
|
|
}
|
|
}
|
|
|
|
func TestCachedHttpClientFunc_HasTimeout(t *testing.T) {
|
|
fn := cachedHttpClientFunc()
|
|
c, _ := fn()
|
|
if c.Timeout == 0 {
|
|
t.Error("expected non-zero timeout")
|
|
}
|
|
}
|
|
|
|
func TestCachedHttpClientFunc_HasRedirectPolicy(t *testing.T) {
|
|
fn := cachedHttpClientFunc()
|
|
c, _ := fn()
|
|
if c.CheckRedirect == nil {
|
|
t.Error("expected CheckRedirect to be set (safeRedirectPolicy)")
|
|
}
|
|
}
|