Track config/config_test.go temporarily

This file was previously ignored as stray. Adding it now so that
its removal can be part of the upcoming production hardening merge
instead of being a silent untracked file.

It will be deleted in a follow-up commit.
This commit is contained in:
2026-05-26 22:40:23 -05:00
parent 9b4bcabd67
commit 29b38efbe7
2 changed files with 68 additions and 3 deletions
-3
View File
@@ -18,8 +18,5 @@
coverage.out
*.test
# Stray/unwanted test file from previous work
config/config_test.go
# Large session-generated review notes
docs/
+68
View File
@@ -0,0 +1,68 @@
package config
import (
"testing"
)
func TestConfig_Validate(t *testing.T) {
tests := []struct {
name string
cfg Config
wantErr bool
}{
{
name: "valid defaults",
cfg: GetDefaultConfig(),
},
{
name: "negative concurrency",
cfg: Config{
MaxConcurrentRequests: -1,
},
wantErr: true,
},
{
name: "invalid memory gc algorithm",
cfg: Config{
Cache: CacheConfig{
Memory: MemoryConfig{
Size: "1GB",
GCAlgorithm: "invalid",
},
},
},
wantErr: true,
},
{
name: "disk enabled without path",
cfg: Config{
Cache: CacheConfig{
Disk: DiskConfig{
Size: "100GB",
GCAlgorithm: "lru",
},
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.cfg.Validate()
if (err != nil) != tt.wantErr {
t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestGetDefaultConfig(t *testing.T) {
def := GetDefaultConfig()
if def.ListenAddress != ":80" {
t.Error("expected default listen address :80")
}
if def.Cache.Memory.Size != "1GB" {
t.Error("expected default memory 1GB")
}
}