mapserver/mapblockaccessor/mapblockaccessor_test.go

46 lines
779 B
Go
Raw Normal View History

2019-01-10 19:50:31 +03:00
package mapblockaccessor
import (
"io/ioutil"
2019-02-05 15:13:34 +03:00
"mapserver/db/sqlite"
2019-01-13 18:37:03 +03:00
"mapserver/testutils"
2023-12-29 18:00:11 +03:00
"mapserver/types"
2019-01-13 18:37:03 +03:00
"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)
2023-12-29 18:00:11 +03:00
mb, err := cache.GetMapBlock(types.NewMapBlockCoords(0, 0, 0))
2019-01-10 19:50:31 +03:00
if err != nil {
panic(err)
}
if mb == nil {
t.Fatal("Mapblock is nil")
}
}