fleet/server/service/service_appconfig_test.go

48 lines
1.2 KiB
Go
Raw Normal View History

package service
import (
"testing"
2017-02-01 17:20:50 +00:00
"github.com/kolide/kolide/server/config"
"github.com/kolide/kolide/server/datastore/inmem"
"github.com/kolide/kolide/server/kolide"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
)
func TestCreateAppConfig(t *testing.T) {
2016-11-25 18:08:22 +00:00
ds, err := inmem.New(config.TestConfig())
require.Nil(t, err)
require.Nil(t, ds.MigrateData())
svc, err := newTestService(ds, nil)
require.Nil(t, err)
var appConfigTests = []struct {
configPayload kolide.AppConfigPayload
}{
{
configPayload: kolide.AppConfigPayload{
OrgInfo: &kolide.OrgInfo{
OrgLogoURL: stringPtr("acme.co/images/logo.png"),
OrgName: stringPtr("Acme"),
},
ServerSettings: &kolide.ServerSettings{
KolideServerURL: stringPtr("https://acme.co:8080/"),
},
},
},
}
for _, tt := range appConfigTests {
result, err := svc.NewAppConfig(context.Background(), tt.configPayload)
require.Nil(t, err)
payload := tt.configPayload
assert.NotEmpty(t, result.ID)
assert.Equal(t, *payload.OrgInfo.OrgLogoURL, result.OrgLogoURL)
assert.Equal(t, *payload.OrgInfo.OrgName, result.OrgName)
assert.Equal(t, *payload.ServerSettings.KolideServerURL, result.KolideServerURL)
}
}