Skip to content

Commit

Permalink
Merge pull request #113 from VB10/feature/ci_for_test
Browse files Browse the repository at this point in the history
chore: Update Flutter test workflow for pull requests to run on the master branch
  • Loading branch information
VB10 authored Sep 2, 2024
2 parents 5a009de + 2a75ee9 commit 1bbed70
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 24 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Flutter Test

on:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- uses: dart-lang/setup-dart@v1
- uses: subosito/flutter-action@v2
with:
channel: "stable"

- name: Flutter Pub Get
run: flutter pub get

- name: Run Tests
run: flutter test

- name: Check Test Results
if: success()
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'All tests passed! 🎉'
})
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ packages:
path: ".."
relative: true
source: path
version: "4.0.4"
version: "4.1.0"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
web:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand Down
Empty file.
37 changes: 18 additions & 19 deletions test/unit/network_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ import 'package:vexana/src/mixin/network_manager_cache.dart';
import 'package:vexana/src/mixin/network_manager_parameters.dart';
import 'package:vexana/vexana.dart';

void main() {
test(' CustomNetworkManager test is valid', () async {
final manager = CustomNetworkManager();
expect(manager, isNotNull);

final primitiveResponse = await manager.sendPrimitive<EmptyModel>('test');
expect(primitiveResponse, isNull);

final downloadFileResponse = await manager.downloadFile('test', null);
expect(downloadFileResponse, isNotNull);

final downloadFileSimpleResponse =
await manager.downloadFileSimple('test', null);
expect(downloadFileSimpleResponse, isNotNull);
});
}

class CustomNetworkManager extends INetworkManager<EmptyModel> {
@override
NetworkManagerCache<INetworkModel<EmptyModel>> get cache =>
Expand Down Expand Up @@ -51,7 +68,7 @@ class CustomNetworkManager extends INetworkManager<EmptyModel> {
CancelToken? cancelToken,
bool isErrorDialog = false,
}) {
return Future.value(ResponseModel(data: EmptyModel() as R));
return Future.value(ResponseModel(data: const EmptyModel() as R));
}

@override
Expand All @@ -68,21 +85,3 @@ class CustomNetworkManager extends INetworkManager<EmptyModel> {
return Future.value(Response<T>(requestOptions: RequestOptions()));
}
}

void main() {
setUp(() {});
test(' CustomNetworkManager test is valid', () async {
final manager = CustomNetworkManager();
expect(manager, isNotNull);

final primitiveResponse = await manager.sendPrimitive<EmptyModel>('test');
expect(primitiveResponse, isNull);

final downloadFileResponse = await manager.downloadFile('test', null);
expect(downloadFileResponse, isNotNull);

final downloadFileSimpleResponse =
await manager.downloadFileSimple('test', null);
expect(downloadFileSimpleResponse, isNotNull);
});
}

0 comments on commit 1bbed70

Please sign in to comment.