1
0
forked from MTSR/mapserver

map obj test

This commit is contained in:
NatureFreshMilk 2019-01-23 14:23:24 +01:00
parent 8a2287fb25
commit fa8c21bc4b
2 changed files with 41 additions and 2 deletions

View File

@ -21,7 +21,6 @@ const addMapDataQuery = `
insert into
objects(x,y,z,posx,posy,posz,type,mtime)
values(?, ?, ?, ?, ?, ?, ?, ?)
returning id
`
const addMapDataAttributeQuery = `
@ -64,7 +63,7 @@ func (db *Sqlite3Accessor) AddMapData(data MapObject) error {
return err
}
}
tx.Commit()
return nil
}

View File

@ -63,3 +63,43 @@ func TestMigrate(t *testing.T) {
}
}
func TestMapObjects(t *testing.T) {
tmpfile, err := ioutil.TempFile("", "TestMapObjects.*.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)
}
attrs := make(map[string]string)
attrs["X"] = "y"
pos := coords.NewMapBlockCoords(0,0,0)
o := MapObject{
MBPos: &pos,
X: 1,
Y: 2,
Z: 3,
Type: "xy",
Mtime: 1234,
Attributes: attrs,
}
err = db.AddMapData(o)
if err != nil {
panic(err)
}
}