detached 3991a6e

fix(favorites): satisfy persistence lint

commit
3991a6ee51c895d45512a9a86db3e3edbe6fe294
author
brice · · 2026-06-28 08:12 UTC
parent
8f314a2
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
3 files · +39 -22
M internal/infrastructure/persistence/sqlite/favorite_repo.go +24 -6
@@ -189,26 +189,41 @@ func favoriteFromRow(row favoriteRow, target *entity.Favorite) *entity.Favorite
189189 }
190190
191191 func favoriteRowFromCreate(row sqlc.CreateFavoriteRow) favoriteRow {
192- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
192+ return favoriteRow{
193+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
194+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
195+ }
193196 }
194197
195198 func favoriteRowFromGetByID(row sqlc.GetFavoriteByIDRow) favoriteRow {
196- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
199+ return favoriteRow{
200+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
201+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
202+ }
197203 }
198204
199205 func favoriteRowFromGetByURL(row sqlc.GetFavoriteByURLRow) favoriteRow {
200- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
206+ return favoriteRow{
207+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
208+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
209+ }
201210 }
202211
203212 func favoriteRowFromGetByShortcut(row sqlc.GetFavoriteByShortcutRow) favoriteRow {
204- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
213+ return favoriteRow{
214+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
215+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
216+ }
205217 }
206218
207219 func favoritesFromAllRows(rows []sqlc.GetAllFavoritesRow) []*entity.Favorite {
208220 favorites := make([]*entity.Favorite, len(rows))
209221 for i := range rows {
210222 row := rows[i]
211- favorites[i] = favoriteFromRow(favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}, nil)
223+ favorites[i] = favoriteFromRow(favoriteRow{
224+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
225+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
226+ }, nil)
212227 }
213228 return favorites
214229 }
@@ -217,7 +232,10 @@ func favoritesFromTagRows(rows []sqlc.GetFavoritesByTagRow) []*entity.Favorite {
217232 favorites := make([]*entity.Favorite, len(rows))
218233 for i := range rows {
219234 row := rows[i]
220- favorites[i] = favoriteFromRow(favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}, nil)
235+ favorites[i] = favoriteFromRow(favoriteRow{
236+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
237+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
238+ }, nil)
221239 }
222240 return favorites
223241 }
@@ -189,26 +189,41 @@ func favoriteFromRow(row favoriteRow, target *entity.Favorite) *entity.Favorite
189 }189 }
190 190
191 func favoriteRowFromCreate(row sqlc.CreateFavoriteRow) favoriteRow {191 func favoriteRowFromCreate(row sqlc.CreateFavoriteRow) favoriteRow {
192- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}192+ return favoriteRow{
193+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
194+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
195+ }
193 }196 }
194 197
195 func favoriteRowFromGetByID(row sqlc.GetFavoriteByIDRow) favoriteRow {198 func favoriteRowFromGetByID(row sqlc.GetFavoriteByIDRow) favoriteRow {
196- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}199+ return favoriteRow{
200+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
201+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
202+ }
197 }203 }
198 204
199 func favoriteRowFromGetByURL(row sqlc.GetFavoriteByURLRow) favoriteRow {205 func favoriteRowFromGetByURL(row sqlc.GetFavoriteByURLRow) favoriteRow {
200- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}206+ return favoriteRow{
207+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
208+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
209+ }
201 }210 }
202 211
203 func favoriteRowFromGetByShortcut(row sqlc.GetFavoriteByShortcutRow) favoriteRow {212 func favoriteRowFromGetByShortcut(row sqlc.GetFavoriteByShortcutRow) favoriteRow {
204- return favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}213+ return favoriteRow{
214+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
215+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
216+ }
205 }217 }
206 218
207 func favoritesFromAllRows(rows []sqlc.GetAllFavoritesRow) []*entity.Favorite {219 func favoritesFromAllRows(rows []sqlc.GetAllFavoritesRow) []*entity.Favorite {
208 favorites := make([]*entity.Favorite, len(rows))220 favorites := make([]*entity.Favorite, len(rows))
209 for i := range rows {221 for i := range rows {
210 row := rows[i]222 row := rows[i]
211- favorites[i] = favoriteFromRow(favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}, nil)223+ favorites[i] = favoriteFromRow(favoriteRow{
224+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
225+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
226+ }, nil)
212 }227 }
213 return favorites228 return favorites
214 }229 }
@@ -217,7 +232,10 @@ func favoritesFromTagRows(rows []sqlc.GetFavoritesByTagRow) []*entity.Favorite {
217 favorites := make([]*entity.Favorite, len(rows))232 favorites := make([]*entity.Favorite, len(rows))
218 for i := range rows {233 for i := range rows {
219 row := rows[i]234 row := rows[i]
220- favorites[i] = favoriteFromRow(favoriteRow{ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl, ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}, nil)235+ favorites[i] = favoriteFromRow(favoriteRow{
236+ ID: row.ID, URL: row.Url, Title: row.Title, FaviconURL: row.FaviconUrl,
237+ ShortcutKey: row.ShortcutKey, Position: row.Position, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt,
238+ }, nil)
221 }239 }
222 return favorites240 return favorites
223 }241 }
M internal/infrastructure/persistence/sqlite/favorite_repo_test.go +4 -4
@@ -23,12 +23,12 @@ func openFavoriteRepoTestDB(t *testing.T) *sql.DB {
2323 return db
2424 }
2525
26-func seedFavoriteWithTags(t *testing.T, db *sql.DB) (entity.FavoriteID, entity.FavoriteID, entity.TagID) {
26+func seedFavoriteWithTags(t *testing.T, db *sql.DB) (entity.FavoriteID, entity.TagID) {
2727 t.Helper()
2828 mustExec(t, db, `INSERT INTO favorites(id, url, title, shortcut_key, position) VALUES (1, 'https://one.example', 'One', 1, 1), (2, 'https://two.example', 'Two', NULL, 2)`)
2929 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'research', '#111111'), (2, 'engines', '#222222')`)
3030 mustExec(t, db, `INSERT INTO favorite_tag_assignments(favorite_id, tag_id) VALUES (1, 1), (1, 2), (2, 1)`)
31- return 1, 2, 1
31+ return 1, 1
3232 }
3333
3434 func TestFavoriteRepositoryGetAllHydratesTags(t *testing.T) {
@@ -49,7 +49,7 @@ func TestFavoriteRepositoryGetAllHydratesTags(t *testing.T) {
4949
5050 func TestFavoriteRepositoryFindByIDHydratesTags(t *testing.T) {
5151 db := openFavoriteRepoTestDB(t)
52- favID, _, _ := seedFavoriteWithTags(t, db)
52+ favID, _ := seedFavoriteWithTags(t, db)
5353 repo := NewFavoriteRepository(db)
5454
5555 fav, err := repo.FindByID(context.Background(), favID)
@@ -73,7 +73,7 @@ func TestFavoriteRepositoryFindByURLHydratesTags(t *testing.T) {
7373
7474 func TestFavoriteRepositoryGetByTagHydratesTags(t *testing.T) {
7575 db := openFavoriteRepoTestDB(t)
76- _, _, tagID := seedFavoriteWithTags(t, db)
76+ _, tagID := seedFavoriteWithTags(t, db)
7777 repo := NewFavoriteRepository(db)
7878
7979 favorites, err := repo.GetByTag(context.Background(), tagID)
@@ -23,12 +23,12 @@ func openFavoriteRepoTestDB(t *testing.T) *sql.DB {
23 return db23 return db
24 }24 }
25 25
26-func seedFavoriteWithTags(t *testing.T, db *sql.DB) (entity.FavoriteID, entity.FavoriteID, entity.TagID) {26+func seedFavoriteWithTags(t *testing.T, db *sql.DB) (entity.FavoriteID, entity.TagID) {
27 t.Helper()27 t.Helper()
28 mustExec(t, db, `INSERT INTO favorites(id, url, title, shortcut_key, position) VALUES (1, 'https://one.example', 'One', 1, 1), (2, 'https://two.example', 'Two', NULL, 2)`)28 mustExec(t, db, `INSERT INTO favorites(id, url, title, shortcut_key, position) VALUES (1, 'https://one.example', 'One', 1, 1), (2, 'https://two.example', 'Two', NULL, 2)`)
29 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'research', '#111111'), (2, 'engines', '#222222')`)29 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'research', '#111111'), (2, 'engines', '#222222')`)
30 mustExec(t, db, `INSERT INTO favorite_tag_assignments(favorite_id, tag_id) VALUES (1, 1), (1, 2), (2, 1)`)30 mustExec(t, db, `INSERT INTO favorite_tag_assignments(favorite_id, tag_id) VALUES (1, 1), (1, 2), (2, 1)`)
31- return 1, 2, 131+ return 1, 1
32 }32 }
33 33
34 func TestFavoriteRepositoryGetAllHydratesTags(t *testing.T) {34 func TestFavoriteRepositoryGetAllHydratesTags(t *testing.T) {
@@ -49,7 +49,7 @@ func TestFavoriteRepositoryGetAllHydratesTags(t *testing.T) {
49 49
50 func TestFavoriteRepositoryFindByIDHydratesTags(t *testing.T) {50 func TestFavoriteRepositoryFindByIDHydratesTags(t *testing.T) {
51 db := openFavoriteRepoTestDB(t)51 db := openFavoriteRepoTestDB(t)
52- favID, _, _ := seedFavoriteWithTags(t, db)52+ favID, _ := seedFavoriteWithTags(t, db)
53 repo := NewFavoriteRepository(db)53 repo := NewFavoriteRepository(db)
54 54
55 fav, err := repo.FindByID(context.Background(), favID)55 fav, err := repo.FindByID(context.Background(), favID)
@@ -73,7 +73,7 @@ func TestFavoriteRepositoryFindByURLHydratesTags(t *testing.T) {
73 73
74 func TestFavoriteRepositoryGetByTagHydratesTags(t *testing.T) {74 func TestFavoriteRepositoryGetByTagHydratesTags(t *testing.T) {
75 db := openFavoriteRepoTestDB(t)75 db := openFavoriteRepoTestDB(t)
76- _, _, tagID := seedFavoriteWithTags(t, db)76+ _, tagID := seedFavoriteWithTags(t, db)
77 repo := NewFavoriteRepository(db)77 repo := NewFavoriteRepository(db)
78 78
79 favorites, err := repo.GetByTag(context.Background(), tagID)79 favorites, err := repo.GetByTag(context.Background(), tagID)
M internal/infrastructure/persistence/sqlite/favorites_migration_test.go +11 -12
@@ -3,7 +3,6 @@ package sqlite
33 import (
44 "context"
55 "database/sql"
6- "fmt"
76 "testing"
87
98 _ "github.com/bnema/purego-sqlite/driver"
@@ -21,15 +20,15 @@ func openMigrationTestDB(t *testing.T) *sql.DB {
2120 return db
2221 }
2322
24-func runMigrationsUpTo(t *testing.T, db *sql.DB, version int64) {
23+func runMigrationsThroughFavoritesSchema(t *testing.T, db *sql.DB) {
2524 t.Helper()
2625 goose.SetBaseFS(embedMigrations)
2726 if err := goose.SetDialect("sqlite3"); err != nil {
2827 t.Fatalf("set dialect: %v", err)
2928 }
3029 goose.SetLogger(goose.NopLogger())
31- if err := goose.UpTo(db, "migrations", version); err != nil {
32- t.Fatalf("migrate to %d: %v", version, err)
30+ if err := goose.UpTo(db, "migrations", 10); err != nil {
31+ t.Fatalf("migrate through favorites schema: %v", err)
3332 }
3433 }
3534
@@ -51,7 +50,7 @@ func countRows(t *testing.T, db *sql.DB, query string, args ...any) int {
5150
5251 func TestFavoritesTagsFirstMigrationFolderPathToTag(t *testing.T) {
5352 db := openMigrationTestDB(t)
54- runMigrationsUpTo(t, db, 10)
53+ runMigrationsThroughFavoritesSchema(t, db)
5554
5655 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (1, 'Research', NULL), (2, 'Browser Engines', 1)`)
5756 mustExec(t, db, `INSERT INTO favorites(id, url, title, folder_id) VALUES (1, 'https://webkit.org', 'WebKit', 2)`)
@@ -69,7 +68,7 @@ func TestFavoritesTagsFirstMigrationFolderPathToTag(t *testing.T) {
6968
7069 func TestFavoritesTagsFirstMigrationFolderTagCollisionSuffix(t *testing.T) {
7170 db := openMigrationTestDB(t)
72- runMigrationsUpTo(t, db, 10)
71+ runMigrationsThroughFavoritesSchema(t, db)
7372
7473 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'dev-go', '#111111')`)
7574 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (7, 'Dev', NULL), (8, 'Go', 7)`)
@@ -88,7 +87,7 @@ func TestFavoritesTagsFirstMigrationFolderTagCollisionSuffix(t *testing.T) {
8887
8988 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsExistingTag(t *testing.T) {
9089 db := openMigrationTestDB(t)
91- runMigrationsUpTo(t, db, 10)
90+ runMigrationsThroughFavoritesSchema(t, db)
9291
9392 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111'), (2, 'foo-folder-3', '#222222')`)
9493 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL)`)
@@ -107,7 +106,7 @@ func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsExistingTag(t *testing.
107106
108107 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsFolderNaturalSlug(t *testing.T) {
109108 db := openMigrationTestDB(t)
110- runMigrationsUpTo(t, db, 10)
109+ runMigrationsThroughFavoritesSchema(t, db)
111110
112111 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111')`)
113112 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL), (4, 'foo-folder-3', NULL)`)
@@ -134,7 +133,7 @@ func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsFolderNaturalSlug(t *te
134133
135134 func TestFavoritesTagsFirstMigrationMergesFoldedDuplicateTags(t *testing.T) {
136135 db := openMigrationTestDB(t)
137- runMigrationsUpTo(t, db, 10)
136+ runMigrationsThroughFavoritesSchema(t, db)
138137
139138 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, ' Dev-Go ', '#111111'), (2, 'dev-go', '#222222')`)
140139 mustExec(t, db, `INSERT INTO favorites(id, url, title) VALUES (1, 'https://one.example', 'One'), (2, 'https://two.example', 'Two')`)
@@ -154,9 +153,9 @@ func TestFavoritesTagsFirstMigrationMergesFoldedDuplicateTags(t *testing.T) {
154153 }
155154 }
156155
157-func mustExec(t *testing.T, db *sql.DB, query string, args ...any) {
156+func mustExec(t *testing.T, db *sql.DB, query string) {
158157 t.Helper()
159- if _, err := db.Exec(query, args...); err != nil {
160- t.Fatalf("exec %s: %v", fmt.Sprintf(query, args...), err)
158+ if _, err := db.Exec(query); err != nil {
159+ t.Fatalf("exec %s: %v", query, err)
161160 }
162161 }
@@ -3,7 +3,6 @@ package sqlite
3 import (3 import (
4 "context"4 "context"
5 "database/sql"5 "database/sql"
6- "fmt"
7 "testing"6 "testing"
8 7
9 _ "github.com/bnema/purego-sqlite/driver"8 _ "github.com/bnema/purego-sqlite/driver"
@@ -21,15 +20,15 @@ func openMigrationTestDB(t *testing.T) *sql.DB {
21 return db20 return db
22 }21 }
23 22
24-func runMigrationsUpTo(t *testing.T, db *sql.DB, version int64) {23+func runMigrationsThroughFavoritesSchema(t *testing.T, db *sql.DB) {
25 t.Helper()24 t.Helper()
26 goose.SetBaseFS(embedMigrations)25 goose.SetBaseFS(embedMigrations)
27 if err := goose.SetDialect("sqlite3"); err != nil {26 if err := goose.SetDialect("sqlite3"); err != nil {
28 t.Fatalf("set dialect: %v", err)27 t.Fatalf("set dialect: %v", err)
29 }28 }
30 goose.SetLogger(goose.NopLogger())29 goose.SetLogger(goose.NopLogger())
31- if err := goose.UpTo(db, "migrations", version); err != nil {30+ if err := goose.UpTo(db, "migrations", 10); err != nil {
32- t.Fatalf("migrate to %d: %v", version, err)31+ t.Fatalf("migrate through favorites schema: %v", err)
33 }32 }
34 }33 }
35 34
@@ -51,7 +50,7 @@ func countRows(t *testing.T, db *sql.DB, query string, args ...any) int {
51 50
52 func TestFavoritesTagsFirstMigrationFolderPathToTag(t *testing.T) {51 func TestFavoritesTagsFirstMigrationFolderPathToTag(t *testing.T) {
53 db := openMigrationTestDB(t)52 db := openMigrationTestDB(t)
54- runMigrationsUpTo(t, db, 10)53+ runMigrationsThroughFavoritesSchema(t, db)
55 54
56 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (1, 'Research', NULL), (2, 'Browser Engines', 1)`)55 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (1, 'Research', NULL), (2, 'Browser Engines', 1)`)
57 mustExec(t, db, `INSERT INTO favorites(id, url, title, folder_id) VALUES (1, 'https://webkit.org', 'WebKit', 2)`)56 mustExec(t, db, `INSERT INTO favorites(id, url, title, folder_id) VALUES (1, 'https://webkit.org', 'WebKit', 2)`)
@@ -69,7 +68,7 @@ func TestFavoritesTagsFirstMigrationFolderPathToTag(t *testing.T) {
69 68
70 func TestFavoritesTagsFirstMigrationFolderTagCollisionSuffix(t *testing.T) {69 func TestFavoritesTagsFirstMigrationFolderTagCollisionSuffix(t *testing.T) {
71 db := openMigrationTestDB(t)70 db := openMigrationTestDB(t)
72- runMigrationsUpTo(t, db, 10)71+ runMigrationsThroughFavoritesSchema(t, db)
73 72
74 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'dev-go', '#111111')`)73 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'dev-go', '#111111')`)
75 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (7, 'Dev', NULL), (8, 'Go', 7)`)74 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (7, 'Dev', NULL), (8, 'Go', 7)`)
@@ -88,7 +87,7 @@ func TestFavoritesTagsFirstMigrationFolderTagCollisionSuffix(t *testing.T) {
88 87
89 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsExistingTag(t *testing.T) {88 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsExistingTag(t *testing.T) {
90 db := openMigrationTestDB(t)89 db := openMigrationTestDB(t)
91- runMigrationsUpTo(t, db, 10)90+ runMigrationsThroughFavoritesSchema(t, db)
92 91
93 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111'), (2, 'foo-folder-3', '#222222')`)92 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111'), (2, 'foo-folder-3', '#222222')`)
94 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL)`)93 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL)`)
@@ -107,7 +106,7 @@ func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsExistingTag(t *testing.
107 106
108 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsFolderNaturalSlug(t *testing.T) {107 func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsFolderNaturalSlug(t *testing.T) {
109 db := openMigrationTestDB(t)108 db := openMigrationTestDB(t)
110- runMigrationsUpTo(t, db, 10)109+ runMigrationsThroughFavoritesSchema(t, db)
111 110
112 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111')`)111 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, 'foo', '#111111')`)
113 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL), (4, 'foo-folder-3', NULL)`)112 mustExec(t, db, `INSERT INTO favorite_folders(id, name, parent_id) VALUES (3, 'Foo', NULL), (4, 'foo-folder-3', NULL)`)
@@ -134,7 +133,7 @@ func TestFavoritesTagsFirstMigrationGeneratedSuffixAvoidsFolderNaturalSlug(t *te
134 133
135 func TestFavoritesTagsFirstMigrationMergesFoldedDuplicateTags(t *testing.T) {134 func TestFavoritesTagsFirstMigrationMergesFoldedDuplicateTags(t *testing.T) {
136 db := openMigrationTestDB(t)135 db := openMigrationTestDB(t)
137- runMigrationsUpTo(t, db, 10)136+ runMigrationsThroughFavoritesSchema(t, db)
138 137
139 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, ' Dev-Go ', '#111111'), (2, 'dev-go', '#222222')`)138 mustExec(t, db, `INSERT INTO favorite_tags(id, name, color) VALUES (1, ' Dev-Go ', '#111111'), (2, 'dev-go', '#222222')`)
140 mustExec(t, db, `INSERT INTO favorites(id, url, title) VALUES (1, 'https://one.example', 'One'), (2, 'https://two.example', 'Two')`)139 mustExec(t, db, `INSERT INTO favorites(id, url, title) VALUES (1, 'https://one.example', 'One'), (2, 'https://two.example', 'Two')`)
@@ -154,9 +153,9 @@ func TestFavoritesTagsFirstMigrationMergesFoldedDuplicateTags(t *testing.T) {
154 }153 }
155 }154 }
156 155
157-func mustExec(t *testing.T, db *sql.DB, query string, args ...any) {156+func mustExec(t *testing.T, db *sql.DB, query string) {
158 t.Helper()157 t.Helper()
159- if _, err := db.Exec(query, args...); err != nil {158+ if _, err := db.Exec(query); err != nil {
160- t.Fatalf("exec %s: %v", fmt.Sprintf(query, args...), err)159+ t.Fatalf("exec %s: %v", query, err)
161 }160 }
162 }161 }

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 8

Tags 42

↑↓ moveenter openesc close