detached a00b616

fix(test): use storedContainerName when verifying attachment migration

extractContainerNameFromAttachmentFile preserves the 'gordon-' prefix
from the filename, but the test was calling GetAllAttachment with the
bare containerName (without prefix), so the lookup returned empty.
Fix by deriving storedContainerName from the filename, matching what
migrateAttachmentEnvFile actually stores in pass.
commit
a00b616404aeedad96c3b8585752a7d193a35f4e
author
brice · · 2026-03-01 11:17 UTC
parent
2c769c5
signature
unsigned
1 file · +6 -3
M internal/app/migrate_env_test.go +6 -3
@@ -110,11 +110,14 @@ func TestMigrateAttachmentEnvFile(t *testing.T) {
110110 require.NoError(t, err)
111111
112112 containerName := fmt.Sprintf("gitea-postgres-%d", time.Now().UnixNano())
113+ envFileName := "gordon-" + containerName + ".env"
114+ // extractContainerNameFromAttachmentFile strips the .env suffix, so the
115+ // stored name includes the "gordon-" prefix from the filename.
116+ storedContainerName := extractContainerNameFromAttachmentFile(envFileName)
113117 keys := []string{"POSTGRES_USER", "POSTGRES_PASSWORD"}
114- defer cleanupPassAttachment(t, containerName, keys)
118+ defer cleanupPassAttachment(t, storedContainerName, keys)
115119
116120 envContent := "POSTGRES_USER=gitea\nPOSTGRES_PASSWORD=secret123\n"
117- envFileName := "gordon-" + containerName + ".env"
118121 envFilePath := filepath.Join(tmpDir, envFileName)
119122 err = os.WriteFile(envFilePath, []byte(envContent), 0600)
120123 require.NoError(t, err)
@@ -129,7 +132,7 @@ func TestMigrateAttachmentEnvFile(t *testing.T) {
129132 _, err = os.Stat(migratedPath)
130133 assert.NoError(t, err, ".env.migrated file should exist")
131134
132- values, err := store.GetAllAttachment(containerName)
135+ values, err := store.GetAllAttachment(storedContainerName)
133136 require.NoError(t, err)
134137 assert.Equal(t, "gitea", values["POSTGRES_USER"])
135138 assert.Equal(t, "secret123", values["POSTGRES_PASSWORD"])
@@ -110,11 +110,14 @@ func TestMigrateAttachmentEnvFile(t *testing.T) {
110 require.NoError(t, err)110 require.NoError(t, err)
111 111
112 containerName := fmt.Sprintf("gitea-postgres-%d", time.Now().UnixNano())112 containerName := fmt.Sprintf("gitea-postgres-%d", time.Now().UnixNano())
113+ envFileName := "gordon-" + containerName + ".env"
114+ // extractContainerNameFromAttachmentFile strips the .env suffix, so the
115+ // stored name includes the "gordon-" prefix from the filename.
116+ storedContainerName := extractContainerNameFromAttachmentFile(envFileName)
113 keys := []string{"POSTGRES_USER", "POSTGRES_PASSWORD"}117 keys := []string{"POSTGRES_USER", "POSTGRES_PASSWORD"}
114- defer cleanupPassAttachment(t, containerName, keys)118+ defer cleanupPassAttachment(t, storedContainerName, keys)
115 119
116 envContent := "POSTGRES_USER=gitea\nPOSTGRES_PASSWORD=secret123\n"120 envContent := "POSTGRES_USER=gitea\nPOSTGRES_PASSWORD=secret123\n"
117- envFileName := "gordon-" + containerName + ".env"
118 envFilePath := filepath.Join(tmpDir, envFileName)121 envFilePath := filepath.Join(tmpDir, envFileName)
119 err = os.WriteFile(envFilePath, []byte(envContent), 0600)122 err = os.WriteFile(envFilePath, []byte(envContent), 0600)
120 require.NoError(t, err)123 require.NoError(t, err)
@@ -129,7 +132,7 @@ func TestMigrateAttachmentEnvFile(t *testing.T) {
129 _, err = os.Stat(migratedPath)132 _, err = os.Stat(migratedPath)
130 assert.NoError(t, err, ".env.migrated file should exist")133 assert.NoError(t, err, ".env.migrated file should exist")
131 134
132- values, err := store.GetAllAttachment(containerName)135+ values, err := store.GetAllAttachment(storedContainerName)
133 require.NoError(t, err)136 require.NoError(t, err)
134 assert.Equal(t, "gitea", values["POSTGRES_USER"])137 assert.Equal(t, "gitea", values["POSTGRES_USER"])
135 assert.Equal(t, "secret123", values["POSTGRES_PASSWORD"])138 assert.Equal(t, "secret123", values["POSTGRES_PASSWORD"])

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close