added initial roadmap and implementation
This commit is contained in:
39
tests/integration/storage.test.ts
Normal file
39
tests/integration/storage.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { createAnonClient, createServiceRoleClient } from './setup.ts';
|
||||
|
||||
const client = createAnonClient();
|
||||
const admin = createServiceRoleClient();
|
||||
const bucket = 'test-bucket';
|
||||
|
||||
describe('Storage', () => {
|
||||
it('should upload a file', async () => {
|
||||
// Use Buffer for Node environment reliability
|
||||
const file = Buffer.from('Hello, MadBase!');
|
||||
// Use admin to bypass RLS/Permission issues for now to verify S3 connectivity
|
||||
const { data, error } = await admin.storage
|
||||
.from(bucket)
|
||||
.upload('hello.txt', file, { upsert: true });
|
||||
|
||||
if (error) console.error('Upload error:', error);
|
||||
expect(error).toBeNull();
|
||||
expect(data).toBeDefined();
|
||||
expect(data?.path).toBe('hello.txt');
|
||||
});
|
||||
|
||||
it('should list files', async () => {
|
||||
const { data, error } = await client.storage.from(bucket).list();
|
||||
|
||||
expect(error).toBeNull();
|
||||
expect(data).toBeDefined();
|
||||
expect(data?.some((f) => f.name === 'hello.txt')).toBe(true);
|
||||
});
|
||||
|
||||
it('should download a file', async () => {
|
||||
const { data, error } = await client.storage.from(bucket).download('hello.txt');
|
||||
|
||||
expect(error).toBeNull();
|
||||
expect(data).toBeDefined();
|
||||
const text = await data?.text();
|
||||
expect(text).toBe('Hello, MadBase!');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user