execute method

  1. @override
Future<void> execute({
  1. required CancelToken cancelToken,
  2. required TestReport report,
  3. required TestController tester,
})

Attempts to locate the Testable identified by the testableId and will then set the associated value to the found widget.

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')";
  log(
    name,
    tester: tester,
  );

  var firestore = TestFirestoreHelper.firestore;

  var doc = firestore.collection(collectionPath).doc(documentId);
  var data = json.decode(value);
  await doc.set(data);
}