chore: configure gin mode
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
2bdad13e5c
commit
ab4f905725
@@ -179,3 +179,54 @@ func TestLoadAppliesFileEnvironmentOverride(t *testing.T) {
|
||||
t.Fatalf("got %d", cfg.File.MaxWriteBytes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultIncludesGinConfig(t *testing.T) {
|
||||
cfg := Default()
|
||||
if cfg.Gin.Mode != "release" {
|
||||
t.Fatalf("Gin.Mode = %q, want release", cfg.Gin.Mode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadParsesGinConfigFromYAML(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.yaml")
|
||||
data := []byte(`gin:
|
||||
mode: "debug"
|
||||
`)
|
||||
if err := os.WriteFile(path, data, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg, err := Load(path)
|
||||
if err != nil {
|
||||
t.Fatalf("Load returned error: %v", err)
|
||||
}
|
||||
if cfg.Gin.Mode != "debug" {
|
||||
t.Fatalf("Gin.Mode = %q, want debug", cfg.Gin.Mode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAppliesGinModeEnvironmentOverride(t *testing.T) {
|
||||
t.Setenv("CODESPACE_GIN_MODE", "test")
|
||||
cfg, err := Load(filepath.Join(t.TempDir(), "missing.yaml"))
|
||||
if err != nil {
|
||||
t.Fatalf("Load returned error: %v", err)
|
||||
}
|
||||
if cfg.Gin.Mode != "test" {
|
||||
t.Fatalf("Gin.Mode = %q, want test", cfg.Gin.Mode)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsInvalidGinMode(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "config.yaml")
|
||||
data := []byte(`gin:
|
||||
mode: "verbose"
|
||||
`)
|
||||
if err := os.WriteFile(path, data, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := Load(path); err == nil {
|
||||
t.Fatal("expected invalid gin mode error")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user