Skip to content

Commit

Permalink
Refine ownership conflict error messages and fix associated tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Dmitrichenko <[email protected]>
  • Loading branch information
errordeveloper committed Jun 10, 2024
1 parent 1564099 commit b8686f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/timoni/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ bundle: {
modPath,
))
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by bundle \"%s\"", instanceName, bundleName)))
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", instanceName, bundleName)))

output, err := executeCommand(fmt.Sprintf("ls -n %[1]s", namespace))
g.Expect(err).ToNot(HaveOccurred())
Expand Down
6 changes: 3 additions & 3 deletions cmd/timoni/bundle_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ bundle: {

_, err = executeCommandWithIn("bundle apply -f - -p main --wait", strings.NewReader(anotherBundleData))
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", "frontend", bundleName)))
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by another bundle \"%s\"", "backend", bundleName)))
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance %q exists and is managed by another bundle %q", "frontend", bundleName)))
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance %q exists and is managed by another bundle %q", "backend", bundleName)))
})

t.Run("fails to create instances from partially overlapping bundle", func(t *testing.T) {
Expand Down Expand Up @@ -247,7 +247,7 @@ bundle: {

_, err = executeCommandWithIn("bundle apply -f - -p main --wait", strings.NewReader(bundleData))
g.Expect(err).To(HaveOccurred())
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is managed by no bundle", instanceName)))
g.Expect(err.Error()).To(ContainSubstring(fmt.Sprintf("instance \"%s\" exists and is not managed by any bundle", instanceName)))
})
}

Expand Down
4 changes: 2 additions & 2 deletions internal/reconciler/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func (e *InstanceOwnershipConflictErr) Error() string {
numConflicts := len(*e)
for i, c := range *e {
if c.CurrentOwnerBundle != "" {
s.WriteString(fmt.Sprintf("instance %q exists and is managed by bundle %q", c.InstanceName, c.CurrentOwnerBundle))
s.WriteString(fmt.Sprintf("instance %q exists and is managed by another bundle %q", c.InstanceName, c.CurrentOwnerBundle))
} else {
s.WriteString(fmt.Sprintf("instance %q exists and is managed by no bundle", c.InstanceName))
s.WriteString(fmt.Sprintf("instance %q exists and is not managed by any bundle", c.InstanceName))
}
if numConflicts > 1 && i != numConflicts {
s.WriteString("; ")
Expand Down

0 comments on commit b8686f0

Please sign in to comment.