fleet/datastore/gorm_app_test.go
Victor Vrantchan 26b1e70ac3 App config api (#223)
Add GET and PATCH endpoints for /kolide/config to get/update current app configuration
2016-09-21 20:45:57 -04:00

51 lines
988 B
Go

package datastore
import (
"os"
"testing"
"github.com/kolide/kolide-ose/kolide"
"github.com/stretchr/testify/assert"
)
func TestOrgInfo(t *testing.T) {
var ds kolide.Datastore
address := os.Getenv("MYSQL_ADDR")
if address == "" {
ds = setup(t)
} else {
ds = setupMySQLGORM(t)
defer teardownMySQLGORM(t, ds)
}
testOrgInfo(t, ds)
}
func testOrgInfo(t *testing.T, db kolide.Datastore) {
info := &kolide.OrgInfo{
OrgName: "Kolide",
OrgLogoURL: "localhost:8080/logo.png",
}
info, err := db.NewOrgInfo(info)
assert.Nil(t, err)
assert.Equal(t, info.ID, uint(1))
info2, err := db.OrgInfo()
assert.Nil(t, err)
assert.Equal(t, info2.ID, uint(1))
assert.Equal(t, info2.OrgName, info.OrgName)
info2.OrgName = "koolide"
err = db.SaveOrgInfo(info2)
assert.Nil(t, err)
info3, err := db.OrgInfo()
assert.Nil(t, err)
assert.Equal(t, info3.OrgName, info2.OrgName)
info4, err := db.NewOrgInfo(info3)
assert.Nil(t, err)
assert.Equal(t, info4.ID, uint(1))
}