supabase/storage-js

client.deleteBucket does not actually delete the bucket

mircea-pavel-anton opened this issue · 1 comments

Bug report

Describe the bug

I am writing some tests for my program that uses the storage-js package. In my tests, i am first checking that the client can create a bucket and later on that it can be deleted.

While the bucket is indeed created and the api response is as expected, the delete method returns a successful api response:

  console.log
    { data: { message: 'Successfully deleted' }, error: null }

      at test/index.test.ts:68:13

However, running the tests again will cause the createBucket method to fail with:

  console.log
    {
      data: null,
      error: {
        message: 'duplicate key value violates unique constraint "buckets_pkey"',
        status: 400
      }
    }

      at test/index.test.ts:38:13

Upon checking in the GUI, indeed, the test-bucket bucket is still there, even though the response indicates that it was deleted.

Note: i am calling emptyBucket() before calling the deleteBucket().

To Reproduce

  1. Create a new storage bucket using `client.createBucket('test-bucket');
  2. Attempt to delete the bucket by calling client.deleteBucket('test-bucket');
  3. Attempt to create the bucket again as in step 1
  4. See the error

Expected behavior

The bucket should be deleted or an appropriate error message should be returned.

System information

  • OS: Ubuntu 20.04
  • Browser (if applies): N/A
  • Version of supabase-js: "@supabase/storage-js": "^1.7.0",
  • Version of Node.js: v17.8.0

Additional context

This test has been done using the hosted supabase instance, not a local one.

... this was an issue with the order Jest executed my tests. The bucket was re-created in subsequent tests. Nevermind.