diff --git a/internal/handlers/log_download_test.go b/internal/handlers/log_download_test.go index 781fd83..595fbee 100644 --- a/internal/handlers/log_download_test.go +++ b/internal/handlers/log_download_test.go @@ -69,6 +69,27 @@ func TestHandleDeploymentLogDownloadServesLegitimateFile(t *testing.T) { assert.Contains(t, recorder.Body.String(), "deploy log contents") } +// TestGetLogFilePathHasNoHostname verifies a deployment log is stored +// directly under logs//, with no hostname directory in between, +// so it is still found after the container is recreated with a new +// hostname. +func TestGetLogFilePathHasNoHostname(t *testing.T) { + t.Parallel() + + testCtx := setupTestHandlers(t) + createdApp := createTestApp(t, testCtx, "log-path-app") + + deployment := models.NewDeployment(testCtx.database) + deployment.AppID = createdApp.ID + + logPath := testCtx.deploySvc.GetLogFilePath(createdApp, deployment) + + assert.Equal(t, + filepath.Join(testCtx.deploySvc.GetLogDir(), createdApp.Name), + filepath.Dir(logPath), + ) +} + // TestHandleDeploymentLogDownloadServesLogFromOldHostnameDir verifies a // log written by an older version, under the hostname of a container that // has since been recreated, can still be downloaded.