30 lines
542 B
Go
30 lines
542 B
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestConfigValidate(t *testing.T) {
|
|
c := Config{
|
|
Endpoint: "https://example.com/api/ingest",
|
|
APIKey: "k",
|
|
PlayersDBPath: "/data/playersDB.json",
|
|
SyncInterval: "5m",
|
|
}
|
|
if err := c.Validate(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
d, err := c.IntervalDuration()
|
|
if err != nil || d != 5*time.Minute {
|
|
t.Fatalf("interval: %v %v", d, err)
|
|
}
|
|
}
|
|
|
|
func TestConfigValidateEmpty(t *testing.T) {
|
|
var c Config
|
|
if err := c.Validate(); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|