2020-10-27 17:17:41 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func assertEqualInt(have int, want int, t *testing.T) {
|
|
|
|
if have != want {
|
|
|
|
t.Errorf("have: %d, want: %d\n", have, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertEqualString(have string, want string, t *testing.T) {
|
|
|
|
if have != want {
|
|
|
|
t.Errorf("have: %s, want: %s\n", have, want)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfigFromFile(t *testing.T) {
|
|
|
|
config, err := ConfigFromFile("example.conf")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
assertEqualInt(config.Port, 4711, t)
|
|
|
|
assertEqualString(config.LinkPrefix, "https://jaf.example.com/", t)
|
2022-08-18 22:04:37 +02:00
|
|
|
assertEqualString(config.FileDir, "/var/www/jaf/", t)
|
2020-10-27 17:17:41 +01:00
|
|
|
assertEqualInt(config.LinkLength, 5, t)
|
|
|
|
}
|