diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-07 23:40:19 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-07 23:40:19 -0600 |
| commit | 46b3ff77f3c2fab7a2a988ac2d7b6752854f0aac (patch) | |
| tree | 62927450c4d4e71427f98aefec70aedd08d110ef /test | |
| parent | fab3353a96af04f8da2ee534ec9184e267378721 (diff) | |
feat: add a favicon.ico
Diffstat (limited to 'test')
| -rw-r--r-- | test/integration/container_test.go | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/test/integration/container_test.go b/test/integration/container_test.go index 625f955..6459fed 100644 --- a/test/integration/container_test.go +++ b/test/integration/container_test.go @@ -17,37 +17,43 @@ import ( ) func TestContainer(t *testing.T) { - t.Run("GET /health", func(t *testing.T) { - image := env.Fetch("IMAGE_TAG", "sparkled:main") - require.NotEmpty(t, image) - - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) - defer cancel() - - container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ - ContainerRequest: testcontainers.ContainerRequest{ - Image: image, - ExposedPorts: []string{"80/tcp"}, - WaitingFor: wait.ForLog("Listening on"), - }, - Started: true, - }) - require.NoError(t, err) - - defer func() { - require.NoError(t, container.Terminate(context.Background())) - - testcontainers.CleanupContainer(t, container) - }() - - endpoint, err := container.Endpoint(ctx, "") - require.NoError(t, err) - - path := "http://" + endpoint + "/health" - client := &http.Client{Timeout: 5 * time.Second} - request, err := http.NewRequestWithContext(ctx, http.MethodGet, path, nil) - response, err := client.Do(request) - require.NoError(t, err) - assert.Equal(t, http.StatusOK, response.StatusCode) + image := env.Fetch("IMAGE_TAG", "sparkled:main") + require.NotEmpty(t, image) + + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + + container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{ + ContainerRequest: testcontainers.ContainerRequest{ + Image: image, + ExposedPorts: []string{"80/tcp"}, + WaitingFor: wait.ForLog("Listening on"), + }, + Started: true, }) + require.NoError(t, err) + + defer func() { + require.NoError(t, container.Terminate(context.Background())) + + testcontainers.CleanupContainer(t, container) + }() + + endpoint, err := container.Endpoint(ctx, "") + require.NoError(t, err) + paths := []string{ + "/health", + "/favicon.ico", + } + + for _, path := range paths { + t.Run(path, func(t *testing.T) { + url := "http://" + endpoint + path + client := &http.Client{Timeout: 5 * time.Second} + request, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + response, err := client.Do(request) + require.NoError(t, err) + assert.Equal(t, http.StatusOK, response.StatusCode) + }) + } } |
