Skip to content

Commit f7b348b

Browse files
committed
fix tests
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent 74dd6d4 commit f7b348b

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

app/controlplane/pkg/biz/organization_integration_test.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *OrgIntegrationTestSuite) TestCreate() {
7373
}
7474

7575
for _, tc := range testCases {
76-
s.T().Run(tc.name, func(_ *testing.T) {
76+
s.Run(tc.name, func() {
7777
org, err := s.Organization.Create(ctx, tc.name)
7878
if tc.expectedError {
7979
s.Error(err)
@@ -166,28 +166,37 @@ func (s *OrgIntegrationTestSuite) TestDeleteOrg() {
166166
assert := assert.New(s.T())
167167
ctx := context.Background()
168168

169-
s.T().Run("invalid org ID", func(t *testing.T) {
169+
s.Run("invalid org ID", func() {
170170
// Invalid org ID
171171
err := s.Organization.Delete(ctx, "invalid")
172172
assert.Error(err)
173173
assert.True(biz.IsErrInvalidUUID(err))
174174
})
175175

176-
s.T().Run("org non existent", func(t *testing.T) {
176+
s.Run("org non existent", func() {
177177
// org not found
178178
err := s.Organization.Delete(ctx, uuid.NewString())
179179
assert.Error(err)
180180
assert.True(biz.IsNotFound(err))
181181
})
182182

183-
s.T().Run("org, integrations and repositories deletion", func(t *testing.T) {
184-
// Mock calls to credentials deletion for both the integration and the OCI repository
185-
s.mockedCredsReaderWriter.On("DeleteCredentials", ctx, "stored-OCI-secret").Return(nil)
183+
s.Run("org soft deletion and membership cleanup", func() {
184+
// With soft-deletion, external credentials are NOT deleted, so no mock expectations
186185

187186
err := s.Organization.Delete(ctx, s.org.ID)
188187
assert.NoError(err)
189188

190-
// Integrations and repo deleted as well
189+
// Org is soft-deleted, so it can't be found
190+
org, err := s.Organization.FindByID(ctx, s.org.ID)
191+
assert.Nil(org)
192+
assert.ErrorAs(err, &biz.ErrNotFound{})
193+
194+
// Memberships are deleted (hard-deleted)
195+
memberships, _, err := s.Membership.ByOrg(ctx, s.org.ID, nil, nil)
196+
assert.NoError(err)
197+
assert.Empty(memberships)
198+
199+
// Related resources become inaccessible through org-scoped queries but remain in DB
191200
integrations, err := s.Integration.List(ctx, s.org.ID)
192201
assert.NoError(err)
193202
assert.Empty(integrations)

0 commit comments

Comments
 (0)