Skip to content

Commit

Permalink
fix: re-create deleted resource (#257)
Browse files Browse the repository at this point in the history
* fix: re-create deleted resource fetch

* feat: passing onlyActive param as const
  • Loading branch information
okysetiawan committed Jul 22, 2024
1 parent 81dd3d0 commit 145c81d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/store/postgres/resource/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ func (r Repository) Create(ctx context.Context, resourceModel *resource.Resource
}

func (r Repository) Update(ctx context.Context, resourceModel *resource.Resource) error {
existing, err := r.ReadByFullName(ctx, resourceModel.Tenant(), resourceModel.Store(), resourceModel.FullName(), true)
// we should fetch include `deleted`, because it also used for re-create `deleted` state resource
const excludeDeleted = false
existing, err := r.ReadByFullName(ctx, resourceModel.Tenant(), resourceModel.Store(), resourceModel.FullName(), excludeDeleted)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/store/postgres/resource/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestPostgresResourceRepository(t *testing.T) {
actualError := repository.Update(ctx, resourceToUpdate)
assert.NoError(t, actualError)

storedResources, err := repository.ReadAll(ctx, tnnt, store, true)
storedResources, err := repository.ReadAll(ctx, tnnt, store, false)
assert.NoError(t, err)
assert.Len(t, storedResources, 1)
assert.EqualValues(t, resourceToUpdate, storedResources[0])
Expand Down

0 comments on commit 145c81d

Please sign in to comment.