Шаги схемы вынесены в свой каталог, и сверка их снова видит

- шаги PocketBase переехали из файла в пакет
  internal/adapter/repo/pocketbase/migrations, файл на шаг с именем
  зарегистрированного шага; туда же имена коллекций, срок сессии — в provider.go
- ключ migrations в docs/.docs.json наведён на этот каталог: прежнее значение
  указывало на несуществующий migrations/, и шаг гейта проходил зелёным при
  всякой правке схемы
- app.go подключает пакет шагов явным пустым импортом: пропавшая ссылка на
  константы унесла бы регистрацию, и хранилище поднялось бы без коллекций
This commit is contained in:
av
2026-08-12 22:03:48 +03:00
parent b46be019fc
commit 4a052ec99b
21 changed files with 235 additions and 183 deletions
+7 -6
View File
@@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"
pbrepo "git.vakhrushev.me/av/transcriber/internal/adapter/repo/pocketbase"
"git.vakhrushev.me/av/transcriber/internal/adapter/repo/pocketbase/migrations"
)
// Проверки этого файла судят допуск: кого пускают к приёму и опросу, чем
@@ -33,11 +34,11 @@ func TestApiRequiresSession(t *testing.T) {
// Ни файла, ни задачи: отказ наступает раньше, чем запись попадает в
// хранилище.
files, err := env.app.FindAllRecords(pbrepo.FilesCollection)
files, err := env.app.FindAllRecords(migrations.FilesCollection)
require.NoError(t, err)
assert.Empty(t, files)
jobs, err := env.app.FindAllRecords(pbrepo.JobsCollection)
jobs, err := env.app.FindAllRecords(migrations.JobsCollection)
require.NoError(t, err)
assert.Empty(t, jobs)
})
@@ -63,7 +64,7 @@ func TestUnknownJobIsIndistinguishableWithoutSession(t *testing.T) {
env.serve(created, createMultipartRequest(t, "test.mp3", []byte("audio")))
require.Equal(t, http.StatusCreated, created.Code)
jobs, err := env.app.FindAllRecords(pbrepo.JobsCollection)
jobs, err := env.app.FindAllRecords(migrations.JobsCollection)
require.NoError(t, err)
require.Len(t, jobs, 1)
@@ -459,7 +460,7 @@ func TestProviderSecretRotationReachesStorage(t *testing.T) {
func TestRecordFileIsProtected(t *testing.T) {
app := newTestStorage(t)
files, err := app.FindCollectionByNameOrId(pbrepo.FilesCollection)
files, err := app.FindCollectionByNameOrId(migrations.FilesCollection)
require.NoError(t, err)
field, ok := files.Fields.GetByName("file").(*core.FileField)
@@ -478,14 +479,14 @@ func TestRecordFileNeedsSession(t *testing.T) {
env.serve(created, createMultipartRequest(t, "test.mp3", []byte("audio content")))
require.Equal(t, http.StatusCreated, created.Code)
files, err := env.app.FindAllRecords(pbrepo.FilesCollection)
files, err := env.app.FindAllRecords(migrations.FilesCollection)
require.NoError(t, err)
require.Len(t, files, 1)
names := files[0].GetStringSlice("file")
require.Len(t, names, 1)
link := "/api/files/" + pbrepo.FilesCollection + "/" + files[0].Id + "/" + names[0]
link := "/api/files/" + migrations.FilesCollection + "/" + files[0].Id + "/" + names[0]
anonymous := httptest.NewRecorder()
env.mux.ServeHTTP(anonymous, httptest.NewRequest(http.MethodGet, link, nil))