init
This commit is contained in:
27
internal/config/loader_test.go
Normal file
27
internal/config/loader_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package config
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestLoadFailsWithMissingFields(t *testing.T) {
|
||||
if _, err := Load(testConfigPath(t, "missing.toml")); err == nil {
|
||||
t.Fatalf("缺失字段的配置应返回错误")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsInvalidDuration(t *testing.T) {
|
||||
cfg := `
|
||||
LogLevel = "info"
|
||||
StoragePath = "./data"
|
||||
CacheTTL = "boom"
|
||||
|
||||
[[Hub]]
|
||||
Name = "docker"
|
||||
Domain = "docker.local"
|
||||
Type = "docker"
|
||||
Upstream = "https://registry-1.docker.io"
|
||||
`
|
||||
path := writeTempConfig(t, cfg)
|
||||
if _, err := Load(path); err == nil {
|
||||
t.Fatalf("无效 Duration 应失败")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user