mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
26b1e70ac3
Add GET and PATCH endpoints for /kolide/config to get/update current app configuration
51 lines
988 B
Go
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))
|
|
}
|