2022-07-27 16:43:24 -08:00
|
|
|
package criteria
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
|
"github.com/onsi/gomega"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var _ = Describe("fields", func() {
|
2026-04-24 19:18:20 -08:00
|
|
|
Describe("LookupField", func() {
|
|
|
|
|
It("finds built-in fields case-insensitively", func() {
|
|
|
|
|
field, ok := LookupField("Title")
|
|
|
|
|
|
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
2026-04-28 16:22:48 -08:00
|
|
|
gomega.Expect(field.Name()).To(gomega.Equal("title"))
|
2026-04-24 19:18:20 -08:00
|
|
|
})
|
|
|
|
|
|
2026-04-28 16:22:48 -08:00
|
|
|
It("resolves aliases to their canonical field name", func() {
|
2026-04-24 19:18:20 -08:00
|
|
|
field, ok := LookupField("albumtype")
|
|
|
|
|
|
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
2026-04-28 16:22:48 -08:00
|
|
|
gomega.Expect(field.Name()).To(gomega.Equal("releasetype"))
|
2026-04-24 19:18:20 -08:00
|
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
It("finds registered tag names", func() {
|
|
|
|
|
AddTagNames([]string{"task3_mood"})
|
|
|
|
|
|
|
|
|
|
field, ok := LookupField("task3_mood")
|
|
|
|
|
|
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
2026-04-28 16:22:48 -08:00
|
|
|
gomega.Expect(field.Name()).To(gomega.Equal("task3_mood"))
|
2026-04-24 19:18:20 -08:00
|
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
It("marks registered numeric tags", func() {
|
|
|
|
|
AddTagNames([]string{"task3_score"})
|
|
|
|
|
AddNumericTags([]string{"task3_score"})
|
|
|
|
|
|
|
|
|
|
field, ok := LookupField("task3_score")
|
|
|
|
|
|
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
|
|
|
|
gomega.Expect(field.IsTag).To(gomega.BeTrue())
|
|
|
|
|
gomega.Expect(field.Numeric).To(gomega.BeTrue())
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
It("finds registered roles", func() {
|
|
|
|
|
AddRoles([]string{"task3_producer"})
|
|
|
|
|
|
|
|
|
|
field, ok := LookupField("task3_producer")
|
|
|
|
|
|
|
|
|
|
gomega.Expect(ok).To(gomega.BeTrue())
|
2026-04-28 16:22:48 -08:00
|
|
|
gomega.Expect(field.Name()).To(gomega.Equal("task3_producer"))
|
2026-04-24 19:18:20 -08:00
|
|
|
gomega.Expect(field.IsRole).To(gomega.BeTrue())
|
2022-07-27 16:43:24 -08:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|