mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-12 04:17:16 +02:00
fix(persistence): make the UpdateImage/Put guard test a real guard
The user object was fetched after UpdateImage, so its in-memory UploadedImage already matched and Put's structs:"-" tag was never exercised. Fetch the stale object first and assert the DB value it would have clobbered survives.
This commit is contained in:
parent
ab2c77f7b2
commit
15d6a2a728
1 changed files with 9 additions and 7 deletions
|
|
@ -107,16 +107,18 @@ var _ = Describe("UserRepository", func() {
|
|||
})
|
||||
|
||||
It("is not erased by a later full-row Put", func() {
|
||||
Expect(repo.UpdateImage(adminUser.ID, "u1_admin.png")).To(Succeed())
|
||||
// Fetched before UpdateImage, so its in-memory UploadedImage is stale: Put must not write it back.
|
||||
stale, err := repo.Get(adminUser.ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(repo.UpdateImage(adminUser.ID, "u2_admin.png")).To(Succeed())
|
||||
|
||||
stale.Name = "Renamed"
|
||||
Expect(repo.Put(stale)).To(Succeed())
|
||||
|
||||
usr, err := repo.Get(adminUser.ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
usr.Name = "Renamed"
|
||||
Expect(repo.Put(usr)).To(Succeed())
|
||||
|
||||
usr, err = repo.Get(adminUser.ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(usr.UploadedImage).To(Equal("u1_admin.png"))
|
||||
Expect(usr.UploadedImage).To(Equal("u2_admin.png"))
|
||||
})
|
||||
|
||||
It("clears the filename when given an empty string", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue