@@ -39,6 +39,35 @@ func TestClient(t *testing.T) {
3939 }
4040}
4141
42+ func TestClient_SetBaseURL (t * testing.T ) {
43+ const mockToken = "mock token"
44+ client := NewClient (mockToken )
45+
46+ // Test default base URL
47+ defaultBaseURL := client .GetBaseURL ()
48+ if defaultBaseURL != openaiAPIURLv1 {
49+ t .Errorf ("Expected default BaseURL to be %q, got %q" , openaiAPIURLv1 , defaultBaseURL )
50+ }
51+
52+ // Test setting a new base URL
53+ const newBaseURL = "https://custom-api.example.com/v1"
54+ client .SetBaseURL (newBaseURL )
55+
56+ // Verify the base URL was updated
57+ updatedBaseURL := client .GetBaseURL ()
58+ if updatedBaseURL != newBaseURL {
59+ t .Errorf ("Expected BaseURL to be %q after SetBaseURL, got %q" , newBaseURL , updatedBaseURL )
60+ }
61+
62+ // Test that the updated base URL is used in fullURL method
63+ suffix := "/chat/completions"
64+ fullURL := client .fullURL (suffix )
65+ expectedFullURL := newBaseURL + suffix
66+ if fullURL != expectedFullURL {
67+ t .Errorf ("Expected fullURL to be %q, got %q" , expectedFullURL , fullURL )
68+ }
69+ }
70+
4271func TestSetCommonHeadersAnthropic (t * testing.T ) {
4372 config := DefaultAnthropicConfig ("mock-token" , "" )
4473 client := NewClientWithConfig (config )
0 commit comments