mapserver/server/mapblockaccessor/mapblockaccessor_test.go
2019-02-05 13:13:34 +01:00

44 lines
721 B
Go

package mapblockaccessor
import (
"github.com/sirupsen/logrus"
"io/ioutil"
"mapserver/coords"
"mapserver/db/sqlite"
"mapserver/testutils"
"os"
"testing"
)
func TestSimpleAccess(t *testing.T) {
logrus.SetLevel(logrus.DebugLevel)
tmpfile, err := ioutil.TempFile("", "TestMigrate.*.sqlite")
if err != nil {
panic(err)
}
defer os.Remove(tmpfile.Name())
testutils.CreateTestDatabase(tmpfile.Name())
a, err := sqlite.New(tmpfile.Name())
if err != nil {
panic(err)
}
err = a.Migrate()
if err != nil {
panic(err)
}
cache := NewMapBlockAccessor(a)
mb, err := cache.GetMapBlock(coords.NewMapBlockCoords(0, 0, 0))
if err != nil {
panic(err)
}
if mb == nil {
t.Fatal("Mapblock is nil")
}
}