-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclient_test.go
36 lines (31 loc) · 1.39 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package openairt //nolint:testpackage // Need to access unexported fields
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestClient(t *testing.T) {
mockToken := "test"
client := NewClient(mockToken)
require.Equal(t, client.config.authToken, mockToken)
config := DefaultConfig(mockToken)
client = NewClientWithConfig(config)
require.Equal(t, mockToken, client.config.authToken)
require.Equal(t, OpenaiRealtimeAPIURLv1, client.config.BaseURL)
require.Equal(t, APITypeOpenAI, client.config.APIType)
url := client.getURL("test-model")
require.Equal(t, OpenaiRealtimeAPIURLv1+"?model=test-model", url)
headers := client.getHeaders()
require.Equal(t, "Bearer "+mockToken, headers.Get("Authorization"))
require.Equal(t, "realtime=v1", headers.Get("OpenAI-Beta"))
azureURL := "wss://my-eastus2-openai-resource.openai.azure.com/openai/realtime"
config = DefaultAzureConfig(mockToken, azureURL)
client = NewClientWithConfig(config)
require.Equal(t, mockToken, client.config.authToken)
require.Equal(t, azureURL, client.config.BaseURL)
require.Equal(t, APITypeAzure, client.config.APIType)
require.Equal(t, azureAPIVersion20241001Preview, client.config.APIVersion)
url = client.getURL("test-model")
require.Equal(t, azureURL+"?api-version="+azureAPIVersion20241001Preview+"&deployment=test-model", url)
headers = client.getHeaders()
require.Equal(t, mockToken, headers.Get("api-key"))
}