diff options
| author | xengineering <me@xengineering.eu> | 2026-03-23 17:40:30 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-23 19:56:36 +0100 |
| commit | 14c0c7fa79f599ddab8fa0b2fd2ee7853fa617fe (patch) | |
| tree | 3f1c31cd7728bfca6a4d415ab2dcceb72c968a83 /config_test.go | |
| parent | 04e6d681f04731c67b9b65fb6a55a21184fd4baa (diff) | |
| download | sia-server-14c0c7fa79f599ddab8fa0b2fd2ee7853fa617fe.tar sia-server-14c0c7fa79f599ddab8fa0b2fd2ee7853fa617fe.tar.zst sia-server-14c0c7fa79f599ddab8fa0b2fd2ee7853fa617fe.zip | |
Test everything in configs/valid
This allows easily to add JSON configuration files testing certain
aspects.
Diffstat (limited to 'config_test.go')
| -rw-r--r-- | config_test.go | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/config_test.go b/config_test.go index c568a34..78d07fb 100644 --- a/config_test.go +++ b/config_test.go @@ -1,14 +1,35 @@ package main import ( + "embed" + "io/fs" "testing" ) -func TestDefaultConfig(t *testing.T) { - config := StartupConfig{} +//go:embed configs/valid/*.json +var valid embed.FS - err := config.FromJSON(defaultConfig) - if err != nil { - t.Fatalf("Failed parsing default config from JSON: %v", err) - } +func TestValidConfigs(t *testing.T) { + fs.WalkDir(valid, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + t.Fatalf("Failed to walk valid config files: %v", err) + } + + if d.IsDir() { + return nil + } + + data, err := valid.ReadFile(path) + if err != nil { + t.Fatalf("Failed to read config from path %s: %v", path, err) + } + + config := StartupConfig{} + err = config.FromJSON(data) + if err != nil { + t.Fatalf("Failed parsing config %s from JSON: %v", path, err) + } + + return nil + }) } |
