Skip to content

Commit

Permalink
SYSENG-1822: panic when faking ResourceWithTag (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPsychick authored Nov 25, 2024
1 parent 42eb1f4 commit 46a1c40
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Some examples, more below in the actual changelog (newer entries are more likely
* (internal) generic client: add hook FilterRequestURLHook (#123, @marioreggiori)
-->

### Added

* api/mock/mock_api_implementation: panic when trying to fake `ResourceWithTag` (#419, @drpsychick)

## [0.7.6] -- 2024-11-04

### Added
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/mock/mock_api_implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ func (a *mockAPI) FakeExisting(o types.Object, tags ...string) string {
a.dataMu.Lock()
defer a.dataMu.Unlock()

// SYSENG-1822: faking ResourceWithTag blindly overwrites object with same identifier.
if _, ok := o.(*corev1.ResourceWithTag); ok {
panic("mock: cannot fake ResourceWithTag, pass tags to the object or use the FakeExisting method")
}

identifier := makeObjectIdentifiable(o)

mao := APIObject{
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/lbaas/v1/e2e_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func unavailableServerConnectionCheck(url string) {
resp, err := http.Get(url)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(resp.StatusCode).To(Equal(http.StatusServiceUnavailable))
}, 5*time.Second, 1*time.Second).Should(Succeed())
}, 60*time.Second, 5*time.Second).Should(Succeed())
})
}

Expand Down
9 changes: 5 additions & 4 deletions pkg/vlan/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ var _ = Describe("vlan client", func() {
summary, err := api.Create(ctx, def)
Expect(err).NotTo(HaveOccurred())
vlanID = summary.Identifier
})
DeferCleanup(func(ctx context.Context) {
err := api.Delete(ctx, vlanID)
Expect(err).NotTo(HaveOccurred())

DeferCleanup(func(ctx context.Context) {
err := api.Delete(ctx, vlanID)
Expect(err).NotTo(HaveOccurred())
})
})

It("lists VLANs including test VLAN", func() {
Expand Down

0 comments on commit 46a1c40

Please sign in to comment.