Skip to content

Commit

Permalink
test with dead and unavailable data
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-lox committed Jan 11, 2025
1 parent cec6252 commit a09f1cb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/ndk/test/usecases/files/blossom_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import '../../mocks/mock_blossom_server.dart';

void main() {
late MockBlossomServer server;
late MockBlossomServer server2;
late Blossom client;

setUp(() async {
server = MockBlossomServer(port: 3000);
server2 = MockBlossomServer(port: 3001);
await server.start();
await server2.start();

final blossomRepo = BlossomRepositoryImpl(
client: HttpRequestDS(http.Client()),
Expand All @@ -33,6 +36,7 @@ void main() {

tearDown(() async {
await server.stop();
await server2.stop();
});

group('Blossom Client Integration Tests', () {
Expand All @@ -56,6 +60,30 @@ void main() {
expect(utf8.decode(getResponse), equals('Hello, Blossom!'));
});

test('Upload and retrieve blob - one out of three', () async {
final testData = Uint8List.fromList(utf8.encode('Hello World!'));

// Upload blob
final uploadResponse = await client.uploadBlob(
data: testData,
serverUrls: ['http://localhost:3000'],
);
expect(uploadResponse.first.success, true);

final sha256 = uploadResponse.first.descriptor!.sha256;

// Retrieve blob
final getResponse = await client.getBlob(
sha256: sha256,
serverUrls: [
'http://dead.example.com',
'http://localhost:3001',
'http://localhost:3000',
],
);
expect(utf8.decode(getResponse), equals('Hello World!'));
});

test('List blobs for user', () async {
// Upload some test blobs first
final testData1 = Uint8List.fromList(utf8.encode('Test 1'));
Expand Down

0 comments on commit a09f1cb

Please sign in to comment.