Files
LocalAI/core/config/usecase_flags_test.go
T
Ettore Di Giacinto db929f4a08 test(config): assert every usecase flag is a distinct bit
FLAG_MOTION and FLAG_UPSCALE were both declared as 1 << 26 on separate
branches, and a merge combined the two const blocks without a conflict.
Add a spec that checks every flag from GetAllModelConfigUsecases() is a
single bit that no other flag uses, so a collision fails the tests.

FLAG_MOTION itself moves to 1 << 27.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-13 08:27:24 +00:00

25 lines
611 B
Go

package config
import (
"math/bits"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Usecase flags", func() {
It("gives every usecase flag its own bit", func() {
seen := map[ModelConfigUsecase]string{}
for name, flag := range GetAllModelConfigUsecases() {
// FLAG_LLM is a composite of other flags by design.
if name == "FLAG_LLM" {
continue
}
Expect(bits.OnesCount64(uint64(flag))).To(Equal(1), "%s must be a single bit", name)
other, dup := seen[flag]
Expect(dup).To(BeFalse(), "%s and %s share a bit", name, other)
seen[flag] = name
}
})
})