Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/common/model/checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CheckRunConclusion extends EnumWithValue {
const CheckRunConclusion._(super.value);

factory CheckRunConclusion._fromValue(String? value) {
if (value == null) {
if (value == null || value == 'null') {
return empty;
}
for (final level in const [
Expand Down
11 changes: 11 additions & 0 deletions test/unit/checks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ const checkRunJson = '''{
const String expectedToString =
'{"name":"mighty_readme","id":4,"external_id":"","status":"completed","head_sha":"","check_suite":{"id":5},"details_url":"https://example.com","started_at":"2018-05-04T01:14:52.000Z","conclusion":"neutral"}';

const String newCheckRun =
'{"name":"New CheckRun","id":12345,"external_id":"","status":"queued","head_sha":"","check_suite":{"id":123456},"details_url":"https://example.com","started_at":"2024-12-05T01:05:24.000Z","conclusion":"null"}';

void main() {
group('Check run', () {
test('CheckRun fromJson', () {
Expand All @@ -110,6 +113,14 @@ void main() {
expect(checkRun.conclusion, CheckRunConclusion.neutral);
});

test('CheckRun from freshly created and encoded', () {
final checkRun = CheckRun.fromJson(jsonDecode(newCheckRun));

expect(checkRun.id, 12345);
expect(checkRun.name, 'New CheckRun');
expect(checkRun.conclusion, CheckRunConclusion.empty);
});

test('CheckRun fromJson for skipped conclusion', () {
/// The checkRun Json is the official Github values
///
Expand Down
Loading