1
0
forked from MTSR/mapserver
mapserver/server/mapblockaccessor/mapblockaccessor_test.go

44 lines
721 B
Go
Raw Normal View History

2019-01-10 19:50:31 +03:00
package mapblockaccessor
import (
2019-01-13 18:37:03 +03:00
"github.com/sirupsen/logrus"
2019-01-10 19:50:31 +03:00
"io/ioutil"
"mapserver/coords"
2019-02-05 15:13:34 +03:00
"mapserver/db/sqlite"
2019-01-13 18:37:03 +03:00
"mapserver/testutils"
"os"
"testing"
2019-01-10 19:50:31 +03:00
)
2019-01-11 12:24:10 +03:00
func TestSimpleAccess(t *testing.T) {
logrus.SetLevel(logrus.DebugLevel)
2019-01-10 19:50:31 +03:00
tmpfile, err := ioutil.TempFile("", "TestMigrate.*.sqlite")
if err != nil {
panic(err)
}
2019-01-11 12:24:10 +03:00
defer os.Remove(tmpfile.Name())
testutils.CreateTestDatabase(tmpfile.Name())
2019-01-10 19:50:31 +03:00
2019-02-05 15:13:34 +03:00
a, err := sqlite.New(tmpfile.Name())
2019-01-10 19:50:31 +03:00
if err != nil {
panic(err)
}
2019-01-11 12:24:10 +03:00
2019-01-10 19:50:31 +03:00
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")
}
}