update
Some checks failed
Pipeline: Test, Lint, Build / Get version info (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test Go code (push) Has been cancelled
Pipeline: Test, Lint, Build / Test JS code (push) Has been cancelled
Pipeline: Test, Lint, Build / Lint i18n files (push) Has been cancelled
Pipeline: Test, Lint, Build / Check Docker configuration (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (darwin/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v5) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v6) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm/v7) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (linux/arm64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/386) (push) Has been cancelled
Pipeline: Test, Lint, Build / Build (windows/amd64) (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to GHCR (push) Has been cancelled
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Has been cancelled
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Has been cancelled
Pipeline: Test, Lint, Build / Build Windows installers (push) Has been cancelled
Pipeline: Test, Lint, Build / Package/Release (push) Has been cancelled
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Has been cancelled
Close stale issues and PRs / stale (push) Has been cancelled
POEditor import / update-translations (push) Has been cancelled

This commit is contained in:
2025-12-08 16:16:23 +01:00
commit c251f174ed
1349 changed files with 194301 additions and 0 deletions

120
model/tag_test.go Normal file
View File

@@ -0,0 +1,120 @@
package model
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Tag", func() {
Describe("NewTag", func() {
It("should create a new tag", func() {
tag := NewTag("genre", "Rock")
tag2 := NewTag("Genre", "Rock")
tag3 := NewTag("Genre", "rock")
Expect(tag2.ID).To(Equal(tag.ID))
Expect(tag3.ID).To(Equal(tag.ID))
})
})
Describe("Tags", func() {
var tags Tags
BeforeEach(func() {
tags = Tags{
"genre": {"Rock", "Pop"},
"artist": {"The Beatles"},
}
})
It("should flatten tags by name", func() {
flat := tags.Flatten("genre")
Expect(flat).To(ConsistOf(
NewTag("genre", "Rock"),
NewTag("genre", "Pop"),
))
})
It("should flatten tags", func() {
flat := tags.FlattenAll()
Expect(flat).To(ConsistOf(
NewTag("genre", "Rock"),
NewTag("genre", "Pop"),
NewTag("artist", "The Beatles"),
))
})
It("should get values by name", func() {
Expect(tags.Values("genre")).To(ConsistOf("Rock", "Pop"))
Expect(tags.Values("artist")).To(ConsistOf("The Beatles"))
})
Describe("Hash", func() {
It("should always return the same value for the same tags ", func() {
tags1 := Tags{
"genre": {"Rock", "Pop"},
}
tags2 := Tags{
"Genre": {"pop", "rock"},
}
Expect(tags1.Hash()).To(Equal(tags2.Hash()))
})
It("should return different values for different tags", func() {
tags1 := Tags{
"genre": {"Rock", "Pop"},
}
tags2 := Tags{
"artist": {"The Beatles"},
}
Expect(tags1.Hash()).ToNot(Equal(tags2.Hash()))
})
})
})
Describe("TagList", func() {
Describe("GroupByFrequency", func() {
It("should return an empty Tags map for an empty TagList", func() {
tagList := TagList{}
groupedTags := tagList.GroupByFrequency()
Expect(groupedTags).To(BeEmpty())
})
It("should handle tags with different frequencies correctly", func() {
tagList := TagList{
NewTag("genre", "Jazz"),
NewTag("genre", "Rock"),
NewTag("genre", "Pop"),
NewTag("genre", "Rock"),
NewTag("artist", "The Rolling Stones"),
NewTag("artist", "The Beatles"),
NewTag("artist", "The Beatles"),
}
groupedTags := tagList.GroupByFrequency()
Expect(groupedTags).To(HaveKeyWithValue(TagName("genre"), []string{"Rock", "Jazz", "Pop"}))
Expect(groupedTags).To(HaveKeyWithValue(TagName("artist"), []string{"The Beatles", "The Rolling Stones"}))
})
It("should sort tags by name when frequency is the same", func() {
tagList := TagList{
NewTag("genre", "Jazz"),
NewTag("genre", "Rock"),
NewTag("genre", "Alternative"),
NewTag("genre", "Pop"),
}
groupedTags := tagList.GroupByFrequency()
Expect(groupedTags).To(HaveKeyWithValue(TagName("genre"), []string{"Alternative", "Jazz", "Pop", "Rock"}))
})
It("should normalize casing", func() {
tagList := TagList{
NewTag("genre", "Synthwave"),
NewTag("genre", "synthwave"),
}
groupedTags := tagList.GroupByFrequency()
Expect(groupedTags).To(HaveKeyWithValue(TagName("genre"), []string{"synthwave"}))
})
})
})
})