mirror-yaf/config_test.go
Leon Richardt 172fff0edb
ref!: use generics to simply testing logic
Notably, this requires us to bump the Go version in order to use
generics. We now use Go 1.19.
2022-08-21 20:30:07 +02:00

23 lines
481 B
Go

package main
import (
"testing"
)
func assertEqual[S comparable](have S, want S, t *testing.T) {
if have != want {
t.Error("have:", have, ", want:", want, "\n")
}
}
func TestConfigFromFile(t *testing.T) {
config, err := ConfigFromFile("example.conf")
if err != nil {
panic(err)
}
assertEqual(config.Port, 4711, t)
assertEqual(config.LinkPrefix, "https://jaf.example.com/", t)
assertEqual(config.FileDir, "/var/www/jaf/", t)
assertEqual(config.LinkLength, 5, t)
}