-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new config relationship function
- Loading branch information
1 parent
a15a9fc
commit 6fce679
Showing
5 changed files
with
149 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package tests | ||
|
||
import ( | ||
"github.com/flanksource/duty/models" | ||
"github.com/flanksource/duty/tests/fixtures/dummy" | ||
ginkgo "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = ginkgo.Describe("Config relationship", ginkgo.Ordered, func() { | ||
ginkgo.It("should return OUTGOING relationships", func() { | ||
var relatedConfigs []models.RelatedConfig | ||
err := DefaultContext.DB().Raw("SELECT * FROM related_configs(?, false)", dummy.KubernetesCluster.ID).Find(&relatedConfigs).Error | ||
Expect(err).To(BeNil()) | ||
|
||
Expect(len(relatedConfigs)).To(Equal(2)) | ||
for _, rc := range relatedConfigs { | ||
Expect(rc.Relation).To(Equal("ClusterNode")) | ||
Expect(rc.Type).To(Equal(models.RelatedConfigTypeOutgoing)) | ||
Expect(rc.Config["id"]).To(BeElementOf([]string{dummy.KubernetesNodeA.ID.String(), dummy.KubernetesNodeB.ID.String()})) | ||
} | ||
}) | ||
|
||
ginkgo.It("should return INCOOMING relationships", func() { | ||
var relatedConfigs []models.RelatedConfig | ||
err := DefaultContext.DB().Raw("SELECT * FROM related_configs(?, false)", dummy.KubernetesNodeA.ID).Find(&relatedConfigs).Error | ||
Expect(err).To(BeNil()) | ||
|
||
Expect(len(relatedConfigs)).To(Equal(1)) | ||
Expect(relatedConfigs[0].Relation).To(Equal("ClusterNode")) | ||
Expect(relatedConfigs[0].Type).To(Equal(models.RelatedConfigTypeIncoming)) | ||
Expect(relatedConfigs[0].Config["id"]).To(Equal(dummy.KubernetesCluster.ID.String())) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters