mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
//go:build azidentity
|
|
|
|
package azure
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNewProviderWithIdentity_Construction(t *testing.T) {
|
|
// DefaultAzureCredential construction itself does not require any env vars;
|
|
// failures surface only on the first GetToken call. Verify we get a
|
|
// non-nil provider back with a token source wired in.
|
|
p, err := NewProviderWithIdentity("https://example.openai.azure.com", "", "ua-test")
|
|
if err != nil {
|
|
t.Fatalf("NewProviderWithIdentity() error = %v", err)
|
|
}
|
|
if p == nil {
|
|
t.Fatal("NewProviderWithIdentity() returned nil provider")
|
|
}
|
|
if p.tokenSource == nil {
|
|
t.Fatal("provider.tokenSource should be set")
|
|
}
|
|
if p.apiKey != "" {
|
|
t.Errorf("provider.apiKey = %q, want empty", p.apiKey)
|
|
}
|
|
}
|
|
|
|
func TestNewProviderWithIdentityAndTimeout_Construction(t *testing.T) {
|
|
p, err := NewProviderWithIdentityAndTimeout("https://example.openai.azure.com", "", "ua-test", 30)
|
|
if err != nil {
|
|
t.Fatalf("NewProviderWithIdentityAndTimeout() error = %v", err)
|
|
}
|
|
if p == nil {
|
|
t.Fatal("returned nil provider")
|
|
}
|
|
if p.httpClient.Timeout.Seconds() != 30 {
|
|
t.Errorf("timeout = %v, want 30s", p.httpClient.Timeout)
|
|
}
|
|
}
|