mirror of
https://github.com/mudler/LocalAI.git
synced 2026-10-28 17:18:49 -04:00
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>
25 lines
611 B
Go
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
|
|
}
|
|
})
|
|
})
|