Tests: Use valid fixture IDs so entity tests pass on MariaDB

MariaDB strict mode rejects empty primary keys and out-of-range or oversized
values that SQLite accepts. Give the affected entity tests valid IDs: existing
fixtures where the row is additive, and throwaway in-range IDs where a real
reference would overwrite seeded data.
This commit is contained in:
Michael Mayer 2026-05-31 00:23:23 +00:00
parent 61a89f9ae0
commit 3c00d6fea9
6 changed files with 9 additions and 13 deletions

View file

@ -103,7 +103,7 @@ func TestFindUserShares(t *testing.T) {
}
func TestUserShare_Create(t *testing.T) {
m := UserShare{}
m := UserShare{UserUID: "uqxc08w3d0ej2283", ShareUID: "as6sg6bxpogaaba7"}
err := m.Create()
if err != nil {

View file

@ -151,7 +151,7 @@ func TestDetails_Create(t *testing.T) {
assert.Error(t, details.Create())
})
t.Run("Success", func(t *testing.T) {
details := Details{PhotoID: 1236799955432}
details := Details{PhotoID: 900000001}
err := details.Create()
@ -161,10 +161,9 @@ func TestDetails_Create(t *testing.T) {
})
}
// TODO fails on mariadb
func TestDetails_Save(t *testing.T) {
t.Run("Success", func(t *testing.T) {
details := Details{PhotoID: 123678955432, UpdatedAt: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC)}
details := Details{PhotoID: 900000002, UpdatedAt: time.Date(2020, 2, 1, 0, 0, 0, 0, time.UTC)}
initialDate := details.UpdatedAt
err := details.Save()

View file

@ -103,7 +103,7 @@ func TestPassword_Invalid(t *testing.T) {
func TestPassword_Create(t *testing.T) {
t.Run("Success", func(t *testing.T) {
p := Password{}
p := Password{UID: "uriku0138hqql4bz"}
err := p.Create()

View file

@ -38,9 +38,8 @@ func TestFirstOrCreatePhotoAlbum(t *testing.T) {
t.Errorf("PhotoUID should be the same: %s %s", result.PhotoUID, model.PhotoUID)
}
})
//TODO fails on mariadb
t.Run("NotYetExistingAlbum", func(t *testing.T) {
model := &PhotoAlbum{}
model := &PhotoAlbum{PhotoUID: "ps6sg6be2lvl0y14", AlbumUID: "as6sg6bipotaab29"}
result := FirstOrCreatePhotoAlbum(model)
if result == nil {
@ -57,10 +56,9 @@ func TestFirstOrCreatePhotoAlbum(t *testing.T) {
})
}
// TODO fails on mariadb
func TestPhotoAlbum_Save(t *testing.T) {
t.Run("Success", func(t *testing.T) {
p := PhotoAlbum{}
p := PhotoAlbum{PhotoUID: "ps6sg6be2lvl0y14", AlbumUID: "as6sg6bipogaab11"}
err := p.Create()

View file

@ -90,12 +90,11 @@ func TestPhotoLabel_Save(t *testing.T) {
t.Fatal(err)
}
})
//TODO fails on mariadb
t.Run("PhotoNotNilAndLabelNotNil", func(t *testing.T) {
label := &Label{LabelName: "LabelSaveUnique", LabelSlug: "unique-slug"}
photo := &Photo{}
photoLabel := PhotoLabel{Photo: photo, Label: label}
photoLabel := PhotoLabel{PhotoID: 900000003, LabelID: 900000004, Photo: photo, Label: label}
err := photoLabel.Save()
if err != nil {
t.Fatal(err)

View file

@ -302,11 +302,11 @@ func TestSubject_Updates(t *testing.T) {
t.Fatal(err)
}
if err := m.Updates(Subject{SubjName: "UpdatedName", SubjType: "UpdatedType"}); err != nil {
if err := m.Updates(Subject{SubjName: "UpdatedName", SubjType: "newtype"}); err != nil {
t.Fatal(err)
} else {
assert.Equal(t, "UpdatedName", m.SubjName)
assert.Equal(t, "UpdatedType", m.SubjType)
assert.Equal(t, "newtype", m.SubjType)
}
})