config: data structures; basic tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia7d6f19a46ec8a4987ea429ec6502f676a6a6964
This commit is contained in:
parent
3fca34dd6f
commit
4c84393286
6 changed files with 185 additions and 0 deletions
44
internal/config/config_test.go
Normal file
44
internal/config/config_test.go
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadConfig_ValidFile(t *testing.T) {
|
||||
cfg, err := Load("../../testdata/config.valid.yaml")
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error, got %v", err)
|
||||
}
|
||||
|
||||
if cfg.Site.Domain != "example.com" {
|
||||
t.Errorf("expected domain 'example.com', got '%s'", cfg.Site.Domain)
|
||||
}
|
||||
|
||||
if cfg.Site.SaltRotation != "daily" {
|
||||
t.Errorf("expected salt_rotation 'daily', got '%s'", cfg.Site.SaltRotation)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadConfig_MissingFile(t *testing.T) {
|
||||
_, err := Load("nonexistent.yaml")
|
||||
if err == nil {
|
||||
t.Fatal("expected error for missing file, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_MaxPathsRequired(t *testing.T) {
|
||||
cfg := &Config{
|
||||
Site: SiteConfig{
|
||||
Domain: "example.com",
|
||||
SaltRotation: "daily",
|
||||
},
|
||||
Limits: LimitsConfig{
|
||||
MaxPaths: 0, // invalid
|
||||
},
|
||||
}
|
||||
|
||||
err := cfg.Validate()
|
||||
if err == nil {
|
||||
t.Fatal("expected validation error for max_paths=0, got nil")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue