Skip to content

Commit

Permalink
redis: fix deletion versioning (#1871)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdoxsey authored and github-actions[bot] committed Feb 9, 2021
1 parent b9faff7 commit db3814e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/storage/redis/redis.go
Expand Up @@ -116,6 +116,7 @@ func (db *DB) Delete(ctx context.Context, id string) (err error) {

// mark it as deleted
record.DeletedAt = timestamppb.Now()
record.Version = formatVersion(version)

return nil
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/redis/redis_test.go
Expand Up @@ -144,11 +144,14 @@ func testDB(t *testing.T) {
}
})
t.Run("delete record", func(t *testing.T) {
original, err := db.Get(ctx, id)
require.NoError(t, err)
assert.NoError(t, db.Delete(ctx, id))
record, err := db.Get(ctx, id)
require.NoError(t, err)
require.NotNil(t, record)
assert.NotNil(t, record.DeletedAt)
assert.NotEqual(t, original.GetVersion(), record.GetVersion())
})
t.Run("clear deleted", func(t *testing.T) {
db.ClearDeleted(ctx, time.Now().Add(time.Second))
Expand Down

0 comments on commit db3814e

Please sign in to comment.