-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic Revert (Part 3): Add supporting test files for the automati…
…c revert feature (#3085) Add supporting fake classes for testing and a new field for the autosubmit query result. *List which issues are fixed by this PR. You must list at least one issue.* Part of flutter/flutter#113867 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
- Loading branch information
1 parent
cc2034e
commit 704ad31
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:auto_submit/model/auto_submit_query_result.dart'; | ||
|
||
import 'package:auto_submit/validations/approval.dart'; | ||
import 'package:auto_submit/validations/validation.dart'; | ||
import 'package:github/github.dart' as github; | ||
|
||
class FakeApproval extends Approval { | ||
FakeApproval({required super.config}); | ||
|
||
ValidationResult? validationResult; | ||
|
||
@override | ||
String get name => 'FakeApproval'; | ||
|
||
/// Implements the code review approval logic. | ||
@override | ||
Future<ValidationResult> validate(QueryResult result, github.PullRequest messagePullRequest) async { | ||
return validationResult ?? ValidationResult(true, Action.REMOVE_LABEL, ''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2023 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:auto_submit/model/auto_submit_query_result.dart'; | ||
import 'package:auto_submit/validations/mergeable.dart'; | ||
import 'package:auto_submit/validations/validation.dart'; | ||
import 'package:github/github.dart' as github; | ||
|
||
class FakeMergeable extends Mergeable { | ||
FakeMergeable({required super.config}); | ||
|
||
ValidationResult? validationResult; | ||
|
||
@override | ||
String get name => 'FakeMergeable'; | ||
|
||
@override | ||
Future<ValidationResult> validate(QueryResult result, github.PullRequest messagePullRequest) async { | ||
return validationResult ?? ValidationResult(true, Action.REMOVE_LABEL, ''); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
auto_submit/test/src/validations/fake_required_check_runs.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2023 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:auto_submit/validations/required_check_runs.dart'; | ||
import 'package:auto_submit/model/auto_submit_query_result.dart' as auto; | ||
|
||
import 'package:auto_submit/validations/validation.dart'; | ||
import 'package:github/github.dart' as github; | ||
|
||
class FakeRequiredCheckRuns extends RequiredCheckRuns { | ||
FakeRequiredCheckRuns({required super.config}); | ||
|
||
ValidationResult? validationResult; | ||
|
||
@override | ||
String get name => 'FakeRequiredCheckRuns'; | ||
|
||
@override | ||
Future<ValidationResult> validate(auto.QueryResult result, github.PullRequest messagePullRequest) async { | ||
return validationResult ?? ValidationResult(true, Action.REMOVE_LABEL, ''); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
auto_submit/test/src/validations/fake_validation_filter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2023 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:auto_submit/validations/validation.dart'; | ||
import 'package:auto_submit/validations/validation_filter.dart'; | ||
|
||
class FakeValidationFilter implements ValidationFilter { | ||
final Set<Validation> validations = {}; | ||
|
||
void registerValidation(Validation newValidation) { | ||
validations.add(newValidation); | ||
} | ||
|
||
@override | ||
Set<Validation> getValidations() { | ||
return validations; | ||
} | ||
} |