execute method
Future<void>
execute({
- required CancelToken cancelToken,
- required TestReport report,
- required TestController tester,
Executes the step. This will first look for the Document then compare the value form the document to the value.
Implementation
@override
Future<void> execute({
required CancelToken cancelToken,
required TestReport report,
required TestController tester,
}) async {
String collectionPath = tester.resolveVariable(this.collectionPath);
String? documentId = tester.resolveVariable(this.documentId);
String? value = tester.resolveVariable(this.value);
assert(collectionPath.isNotEmpty == true);
assert(documentId?.isNotEmpty == true);
var name = "$id('$collectionPath', '$documentId', '$value', '$equals')";
log(
name,
tester: tester,
);
var firestore = TestFirestoreHelper.firestore;
var doc = firestore.collection(collectionPath).doc(documentId);
var data = json.encode((await doc.get()).data());
if ((data == value) != equals) {
throw Exception(
'document: [$collectionPath/$documentId] -- actualValue: [$data] ${equals == true ? '!=' : '=='} [$value].',
);
}
}