Skip to content

Commit

Permalink
ci: updates to improve e2e tests (#12343)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Feb 20, 2024
1 parent 376310f commit bd2a678
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/all_plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- uses: Homebrew/actions/setup-homebrew@master
- name: 'Install Tools'
run: |
brew install python3
alias python=python3
flutter pub global activate flutter_plugin_tools
brew install swiftformat
brew install clang-format
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
import 'dart:async';
import 'dart:math';

Expand All @@ -11,16 +10,16 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';

String getCurrentPlatform() {
if (kIsWeb) {
return 'web';
} else if (Platform.isAndroid) {
if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) {
return 'android';
} else if (Platform.isIOS) {
} else if (!kIsWeb && defaultTargetPlatform == TargetPlatform.iOS) {
return 'ios';
} else if (Platform.isMacOS) {
} else if (!kIsWeb && defaultTargetPlatform == TargetPlatform.macOS) {
return 'macos';
} else if (Platform.isWindows) {
} else if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) {
return 'windows';
} else if (kIsWeb) {
return 'web';
} else {
return 'unknown';
}
Expand All @@ -45,7 +44,7 @@ void runSecondDatabaseTests() {

CollectionReference<Map<String, dynamic>> collection =
firestore.collection(
'$collectionForSecondDatabase/$id/${getCurrentPlatform()}',
'$collectionForSecondDatabase/${getCurrentPlatform()}/$id',
);
QuerySnapshot<Map<String, dynamic>> snapshot = await collection.get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,40 @@ void runTransactionTests() {
}
});

testWidgets('should not collide if number of maxAttempts is enough',
(_) async {
DocumentReference<Map<String, dynamic>> doc1 =
await initializeTest('transaction-maxAttempts-1');
testWidgets(
'should not collide if number of maxAttempts is enough',
(_) async {
DocumentReference<Map<String, dynamic>> doc1 =
await initializeTest('transaction-maxAttempts-1');

await doc1.set({'test': 0});
await doc1.set({'test': 0});

await Future.wait([
firestore.runTransaction(
(Transaction transaction) async {
final value = await transaction.get(doc1);
transaction.set(doc1, {
'test': value['test'] + 1,
});
},
maxAttempts: 2,
),
firestore.runTransaction(
(Transaction transaction) async {
final value = await transaction.get(doc1);
transaction.set(doc1, {
'test': value['test'] + 1,
});
},
maxAttempts: 2,
),
]);
await Future.wait([
firestore.runTransaction(
(Transaction transaction) async {
final value = await transaction.get(doc1);
transaction.set(doc1, {
'test': value['test'] + 1,
});
},
maxAttempts: 2,
),
firestore.runTransaction(
(Transaction transaction) async {
final value = await transaction.get(doc1);
transaction.set(doc1, {
'test': value['test'] + 1,
});
},
maxAttempts: 2,
),
]);

DocumentSnapshot<Map<String, dynamic>> snapshot1 = await doc1.get();
expect(snapshot1.data()!['test'], equals(2));
});
DocumentSnapshot<Map<String, dynamic>> snapshot1 = await doc1.get();
expect(snapshot1.data()!['test'], equals(2));
},
retry: 2,
);

testWidgets('should collide if number of maxAttempts is too low',
(_) async {
Expand Down

0 comments on commit bd2a678

Please sign in to comment.