Check / check (pull_request) Waiting to run
An app with no volume mounts now shows, in its Volume Mounts section, that the files it writes are lost whenever a deploy or rollback replaces its container and that a restart keeps them. Each deploy of such an app writes the same sentence into its log, after the webhook payload and before the clone. The README says in one sentence that a deploy or rollback starts a new container that keeps only the files in the app's volume mounts. Model: opus-5-5
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package handlers_test
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"sneak.berlin/go/upaas/internal/models"
|
|
"sneak.berlin/go/upaas/internal/service/deploy"
|
|
)
|
|
|
|
// TestAppPageSaysFilesAreLostOnlyWhenAppHasNoVolumes checks that the app page
|
|
// shows deploy.NoVolumesWarning until the app gets a volume mount.
|
|
func TestAppPageSaysFilesAreLostOnlyWhenAppHasNoVolumes(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
testCtx := setupTestHandlers(t)
|
|
createdApp := createTestApp(t, testCtx, "no-volumes-app")
|
|
|
|
renderAppPage := func() string {
|
|
request := httptest.NewRequestWithContext(
|
|
t.Context(), http.MethodGet, "/apps/"+createdApp.ID, nil,
|
|
)
|
|
request = addChiURLParams(request, map[string]string{"id": createdApp.ID})
|
|
recorder := httptest.NewRecorder()
|
|
|
|
testCtx.handlers.HandleAppDetail().ServeHTTP(recorder, request)
|
|
require.Equal(t, http.StatusOK, recorder.Code)
|
|
|
|
return recorder.Body.String()
|
|
}
|
|
|
|
assert.Contains(t, renderAppPage(), deploy.NoVolumesWarning)
|
|
|
|
volume := models.NewVolume(testCtx.database)
|
|
volume.AppID = createdApp.ID
|
|
volume.HostPath = "/srv/no-volumes-app"
|
|
volume.ContainerPath = "/data"
|
|
require.NoError(t, volume.Save(t.Context()))
|
|
|
|
assert.NotContains(t, renderAppPage(), deploy.NoVolumesWarning)
|
|
}
|