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

46 lines
781 B
Go
Raw Normal View History

2019-01-10 19:50:31 +03:00
package mapblockaccessor
import (
"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-02-22 21:13:47 +03:00
"time"
"github.com/sirupsen/logrus"
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)
}
2019-03-13 11:12:22 +03:00
cache := NewMapBlockAccessor(a, 500*time.Millisecond, 1000*time.Millisecond, 1000)
2019-01-10 19:50:31 +03:00
mb, err := cache.GetMapBlock(coords.NewMapBlockCoords(0, 0, 0))
if err != nil {
panic(err)
}
if mb == nil {
t.Fatal("Mapblock is nil")
}
}