2019-01-14 14:38:26 +03:00
|
|
|
package tiledb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
2019-01-16 18:36:28 +03:00
|
|
|
"mapserver/coords"
|
2019-01-14 14:38:26 +03:00
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMigrate(t *testing.T) {
|
|
|
|
tmpfile, err := ioutil.TempFile("", "TestMigrateEmpty.*.sqlite")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer os.Remove(tmpfile.Name())
|
|
|
|
|
|
|
|
db, err := NewSqliteAccessor(tmpfile.Name())
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = db.Migrate()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-01-14 14:48:46 +03:00
|
|
|
|
2019-01-16 18:36:28 +03:00
|
|
|
pos := coords.NewTileCoords(0, 0, 13)
|
2019-01-14 14:48:46 +03:00
|
|
|
_, err = db.GetTile(0, pos)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2019-01-16 18:36:28 +03:00
|
|
|
data := []byte{}
|
|
|
|
tile := Tile{LayerId: 0, Pos: pos, Data: data}
|
|
|
|
err = db.SetTile(&tile)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-01-14 14:48:46 +03:00
|
|
|
|
2019-01-14 14:38:26 +03:00
|
|
|
}
|