should allow one default datasource per organisation using provisioning

This commit is contained in:
Marcus Efraimsson
2018-08-14 14:48:14 +02:00
parent e521e7b76d
commit aed89b49c0
4 changed files with 45 additions and 4 deletions
@@ -19,6 +19,7 @@ var (
allProperties = "testdata/all-properties"
versionZero = "testdata/version-0"
brokenYaml = "testdata/broken-yaml"
multipleOrgsWithDefault = "testdata/multiple-org-default"
fakeRepo *fakeRepository
)
@@ -73,6 +74,19 @@ func TestDatasourceAsConfig(t *testing.T) {
})
})
Convey("Multiple datasources in different organizations with is_default in each organization", func() {
dc := newDatasourceProvisioner(logger)
err := dc.applyChanges(multipleOrgsWithDefault)
Convey("should not raise error", func() {
So(err, ShouldBeNil)
So(len(fakeRepo.inserted), ShouldEqual, 4)
So(fakeRepo.inserted[0].IsDefault, ShouldBeTrue)
So(fakeRepo.inserted[0].OrgId, ShouldEqual, 1)
So(fakeRepo.inserted[2].IsDefault, ShouldBeTrue)
So(fakeRepo.inserted[2].OrgId, ShouldEqual, 2)
})
})
Convey("Two configured datasource and purge others ", func() {
Convey("two other datasources in database", func() {
fakeRepo.loadAll = []*models.DataSource{