Skip to content

Commit 6a5f07f

Browse files
committed
fix: wrong test file
1 parent 1c68b7f commit 6a5f07f

File tree

2 files changed

+76
-76
lines changed

2 files changed

+76
-76
lines changed

catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/database/dao/documents_dao_test.dart

+1-75
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart';
22
import 'package:catalyst_voices_repositories/src/database/catalyst_database.dart';
33
import 'package:catalyst_voices_repositories/src/database/database.dart';
44
import 'package:collection/collection.dart';
5-
import 'package:drift/drift.dart' show DatabaseConnection, Uint8List;
5+
import 'package:drift/drift.dart' show DatabaseConnection;
66
import 'package:drift/native.dart';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:uuid_plus/uuid_plus.dart';
@@ -440,80 +440,6 @@ void main() {
440440
equals([document2.document]),
441441
);
442442
});
443-
test('authors are correctly extracted', () async {
444-
final authorId1 = CatalystId(host: 'test', role0Key: Uint8List(32));
445-
final authorId2 = CatalystId(host: 'test1', role0Key: Uint8List(32));
446-
447-
final ref = DraftRef.generateFirstRef();
448-
// Given
449-
final draft = DraftFactory.build(
450-
metadata: DocumentDataMetadata(
451-
type: DocumentType.proposalDocument,
452-
selfRef: ref,
453-
authors: [
454-
authorId1,
455-
authorId2,
456-
],
457-
),
458-
);
459-
460-
await database.draftsDao.save(draft);
461-
final doc = await database.draftsDao.query(ref: ref);
462-
expect(
463-
doc?.metadata.authors,
464-
[
465-
authorId1,
466-
authorId2,
467-
],
468-
);
469-
});
470-
471-
test('when updating proposal author list is not deleted', () async {
472-
final authorId1 = CatalystId(host: 'test', role0Key: Uint8List(32));
473-
final authorId2 = CatalystId(host: 'test1', role0Key: Uint8List(32));
474-
475-
final ref = DraftRef.generateFirstRef();
476-
// Given
477-
final draft = DraftFactory.build(
478-
metadata: DocumentDataMetadata(
479-
type: DocumentType.proposalDocument,
480-
selfRef: ref,
481-
authors: [
482-
authorId1,
483-
authorId2,
484-
],
485-
),
486-
content: const DocumentDataContent({
487-
'title': 'Dev',
488-
}),
489-
);
490-
491-
final updateDraft = draft.copyWith(
492-
metadata: draft.metadata.copyWith(
493-
authors: null,
494-
),
495-
content: const DocumentDataContent({
496-
'title': 'Update',
497-
}),
498-
);
499-
500-
await database.draftsDao.save(draft);
501-
await database.draftsDao.save(updateDraft);
502-
503-
final updated = await database.draftsDao.query(ref: ref);
504-
505-
expect(
506-
updated?.metadata.authors?.length,
507-
equals(2),
508-
);
509-
expect(
510-
updated?.metadata.authors,
511-
equals([
512-
authorId1,
513-
authorId2,
514-
]),
515-
);
516-
});
517443
});
518444

519445
group('count', () {

catalyst_voices/packages/internal/catalyst_voices_repositories/test/src/database/dao/drafts_dao_test.dart

+75-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart';
22
import 'package:catalyst_voices_repositories/catalyst_voices_repositories.dart';
33
import 'package:catalyst_voices_repositories/src/database/catalyst_database.dart';
44
import 'package:catalyst_voices_repositories/src/database/dao/drafts_dao.dart';
5-
import 'package:drift/drift.dart' show DatabaseConnection;
5+
import 'package:drift/drift.dart' show DatabaseConnection, Uint8List;
66
import 'package:drift/native.dart';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:uuid_plus/uuid_plus.dart';
@@ -133,6 +133,80 @@ void main() {
133133
allOf(hasLength(refs.length), containsAll(refs)),
134134
);
135135
});
136+
test('authors are correctly extracted', () async {
137+
final authorId1 = CatalystId(host: 'test', role0Key: Uint8List(32));
138+
final authorId2 = CatalystId(host: 'test1', role0Key: Uint8List(32));
139+
140+
final ref = DraftRef.generateFirstRef();
141+
// Given
142+
final draft = DraftFactory.build(
143+
metadata: DocumentDataMetadata(
144+
type: DocumentType.proposalDocument,
145+
selfRef: ref,
146+
authors: [
147+
authorId1,
148+
authorId2,
149+
],
150+
),
151+
);
152+
153+
await database.draftsDao.save(draft);
154+
final doc = await database.draftsDao.query(ref: ref);
155+
expect(
156+
doc?.metadata.authors,
157+
[
158+
authorId1,
159+
authorId2,
160+
],
161+
);
162+
});
163+
164+
test('when updating proposal author list is not deleted', () async {
165+
final authorId1 = CatalystId(host: 'test', role0Key: Uint8List(32));
166+
final authorId2 = CatalystId(host: 'test1', role0Key: Uint8List(32));
167+
168+
final ref = DraftRef.generateFirstRef();
169+
// Given
170+
final draft = DraftFactory.build(
171+
metadata: DocumentDataMetadata(
172+
type: DocumentType.proposalDocument,
173+
selfRef: ref,
174+
authors: [
175+
authorId1,
176+
authorId2,
177+
],
178+
),
179+
content: const DocumentDataContent({
180+
'title': 'Dev',
181+
}),
182+
);
183+
184+
final updateDraft = draft.copyWith(
185+
metadata: draft.metadata.copyWith(
186+
authors: null,
187+
),
188+
content: const DocumentDataContent({
189+
'title': 'Update',
190+
}),
191+
);
192+
193+
await database.draftsDao.save(draft);
194+
await database.draftsDao.save(updateDraft);
195+
196+
final updated = await database.draftsDao.query(ref: ref);
197+
198+
expect(
199+
updated?.metadata.authors?.length,
200+
equals(2),
201+
);
202+
expect(
203+
updated?.metadata.authors,
204+
equals([
205+
authorId1,
206+
authorId2,
207+
]),
208+
);
209+
});
136210
});
137211

138212
group('count', () {

0 commit comments

Comments
 (0)