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

62
utils/gg/gg_test.go Normal file
View File

@@ -0,0 +1,62 @@
package gg_test
import (
"testing"
"github.com/navidrome/navidrome/tests"
"github.com/navidrome/navidrome/utils/gg"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestGG(t *testing.T) {
tests.Init(t, false)
RegisterFailHandler(Fail)
RunSpecs(t, "GG Suite")
}
var _ = Describe("GG", func() {
Describe("P", func() {
It("returns a pointer to the input value", func() {
v := 123
Expect(gg.P(123)).To(Equal(&v))
})
It("returns nil if the input value is zero", func() {
v := 0
Expect(gg.P(0)).To(Equal(&v))
})
})
Describe("V", func() {
It("returns the value of the input pointer", func() {
v := 123
Expect(gg.V(&v)).To(Equal(123))
})
It("returns a zero value if the input pointer is nil", func() {
var v *int
Expect(gg.V(v)).To(Equal(0))
})
})
Describe("If", func() {
It("returns the first value if the condition is true", func() {
Expect(gg.If(true, 1, 2)).To(Equal(1))
})
It("returns the second value if the condition is false", func() {
Expect(gg.If(false, 1, 2)).To(Equal(2))
})
It("works with string values", func() {
Expect(gg.If(true, "a", "b")).To(Equal("a"))
Expect(gg.If(false, "a", "b")).To(Equal("b"))
})
It("works with different types", func() {
Expect(gg.If(true, 1.1, 2.2)).To(Equal(1.1))
Expect(gg.If(false, 1.1, 2.2)).To(Equal(2.2))
})
})
})