Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
52
backend/sdk/cliproxy/usage/manager_test.go
Normal file
52
backend/sdk/cliproxy/usage/manager_test.go
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
package usage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGenerateEnabledDefaultsNilToTrue(t *testing.T) {
|
||||
if !GenerateEnabled(nil) {
|
||||
t.Fatalf("GenerateEnabled(nil) = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateEnabledHonorsExplicitFalse(t *testing.T) {
|
||||
if GenerateEnabled(GenerateFlag(false)) {
|
||||
t.Fatalf("GenerateEnabled(false) = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateEnabledHonorsExplicitTrue(t *testing.T) {
|
||||
if !GenerateEnabled(GenerateFlag(true)) {
|
||||
t.Fatalf("GenerateEnabled(true) = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateFromContextDefaultsMissingToTrue(t *testing.T) {
|
||||
if !GenerateFromContext(context.Background()) {
|
||||
t.Fatalf("GenerateFromContext(background) = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateFromContextHonorsExplicitFalse(t *testing.T) {
|
||||
ctx := WithGenerate(context.Background(), false)
|
||||
if GenerateFromContext(ctx) {
|
||||
t.Fatalf("GenerateFromContext(false) = true, want false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecordOmittedGenerateIsEnabled(t *testing.T) {
|
||||
// Existing callers construct Record without setting Generate.
|
||||
// Omission must remain distinguishable from explicit false and default to true.
|
||||
record := Record{
|
||||
Provider: "openai",
|
||||
Model: "gpt-5.4",
|
||||
}
|
||||
if record.Generate != nil {
|
||||
t.Fatalf("Record.Generate = %v, want nil for omitted field", record.Generate)
|
||||
}
|
||||
if !GenerateEnabled(record.Generate) {
|
||||
t.Fatalf("GenerateEnabled(omitted) = false, want true")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue