2019-01-04 15:02:17 +03:00
|
|
|
package worldconfig_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-01-05 19:21:24 +03:00
|
|
|
"fmt"
|
2019-01-04 15:02:17 +03:00
|
|
|
worldconfig "mapserver/worldconfig"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSqlite(t *testing.T) {
|
|
|
|
cfg := worldconfig.Parse("./testdata/world.mt.sqlite")
|
|
|
|
if cfg.Backend != worldconfig.BACKEND_SQLITE3 {
|
|
|
|
t.Fatal("not sqlite3")
|
|
|
|
}
|
|
|
|
if cfg.PlayerBackend != worldconfig.BACKEND_FILES {
|
|
|
|
t.Fatal("not files")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParsePostgres(t *testing.T) {
|
|
|
|
cfg := worldconfig.Parse("./testdata/world.mt.postgres")
|
2019-01-05 19:21:24 +03:00
|
|
|
fmt.Println(cfg)
|
2019-01-04 15:02:17 +03:00
|
|
|
if cfg.Backend != worldconfig.BACKEND_POSTGRES {
|
|
|
|
t.Fatal("not postgres")
|
|
|
|
}
|
2019-01-04 17:02:25 +03:00
|
|
|
|
2019-01-04 15:02:17 +03:00
|
|
|
if cfg.PlayerBackend != worldconfig.BACKEND_POSTGRES {
|
|
|
|
t.Fatal("not postgres")
|
|
|
|
}
|
2019-01-04 17:02:25 +03:00
|
|
|
|
2019-01-04 18:10:21 +03:00
|
|
|
if cfg.PsqlConnection.Host != "postgres" {
|
2019-01-04 17:02:25 +03:00
|
|
|
t.Fatal("param err")
|
|
|
|
}
|
2019-01-04 18:30:18 +03:00
|
|
|
|
|
|
|
if cfg.PsqlConnection.Port != 5432 {
|
|
|
|
t.Fatal("param err: ", cfg.PsqlConnection.Port)
|
|
|
|
}
|
2019-01-04 15:02:17 +03:00
|
|
|
}
|