|
|
@@ -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{
|