Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download api/pkg/discord/client_option_test.go from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/client_option_test.go
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway/api/pkg/discord/client_option_test.go
-
curl -L -o client_option_test.go https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/main/api/pkg/discord/client_option_test.go
1.38 kB
| package discord | |
| import ( | |
| "net/http" | |
| "testing" | |
| "github.com/stretchr/testify/assert" | |
| ) | |
| func TestWithHTTPClient(t *testing.T) { | |
| t.Run("httpClient is not set when the httpClient is nil", func(t *testing.T) { | |
| // Setup | |
| t.Parallel() | |
| // Arrange | |
| config := defaultClientConfig() | |
| // Act | |
| WithHTTPClient(nil).apply(config) | |
| // Assert | |
| assert.NotNil(t, config.httpClient) | |
| }) | |
| t.Run("httpClient is set when the httpClient is not nil", func(t *testing.T) { | |
| // Setup | |
| t.Parallel() | |
| // Arrange | |
| config := defaultClientConfig() | |
| newClient := &http.Client{Timeout: 300} | |
| // Act | |
| WithHTTPClient(newClient).apply(config) | |
| // Assert | |
| assert.NotNil(t, config.httpClient) | |
| assert.Equal(t, newClient.Timeout, config.httpClient.Timeout) | |
| }) | |
| } | |
| func TestWithBaseURL(t *testing.T) { | |
| t.Run("baseURL is set successfully", func(t *testing.T) { | |
| // Setup | |
| t.Parallel() | |
| // Arrange | |
| baseURL := "https://example.com" | |
| config := defaultClientConfig() | |
| // Act | |
| WithBaseURL(baseURL).apply(config) | |
| // Assert | |
| assert.Equal(t, config.baseURL, config.baseURL) | |
| }) | |
| t.Run("tailing / is trimmed from baseURL", func(t *testing.T) { | |
| // Setup | |
| t.Parallel() | |
| // Arrange | |
| baseURL := "https://example.com/" | |
| config := defaultClientConfig() | |
| // Act | |
| WithBaseURL(baseURL).apply(config) | |
| // Assert | |
| assert.Equal(t, "https://example.com", config.baseURL) | |
| }) | |
| } | |