Skip to content

Commit

Permalink
Add unit test for make outputArtifactPath
Browse files Browse the repository at this point in the history
  • Loading branch information
lijy91 committed Nov 26, 2024
1 parent 39225ac commit 569a490
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/flutter_app_packager/lib/src/api/make_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class MakeConfig {
return _pubspec!;
}

set pubspec(Pubspec pubspec) {
_pubspec = pubspec;
}

Map<String, dynamic> toJson() {
return {
'isInstaller': isInstaller,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter_app_packager/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ dependencies:
dev_dependencies:
dependency_validator: ^3.0.0
mostly_reasonable_lints: ^0.1.2
test: ^1.23.1
45 changes: 45 additions & 0 deletions packages/flutter_app_packager/test/src/api/make_config_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'dart:io';

import 'package:flutter_app_packager/src/api/make_config.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:pubspec_parse/pubspec_parse.dart';
import 'package:test/test.dart';

void main() {
group('MakeConfig', () {
test('#1', () {
final makeConfig = MakeConfig()
..buildMode = 'release'
..buildOutputDirectory = Directory('build')
..buildOutputFiles = []
..platform = 'android'
..packageFormat = 'apk'
..outputDirectory = Directory('dist/')
..pubspec = Pubspec(
'test_app',
version: Version.parse('1.0.0'),
);
expect(
makeConfig.outputArtifactPath,
'dist/1.0.0/test_app-1.0.0-android.apk',
);
});
test('#2', () {
final makeConfig = MakeConfig()
..buildMode = 'release'
..buildOutputDirectory = Directory('build')
..buildOutputFiles = []
..platform = 'android'
..packageFormat = 'apk'
..outputDirectory = Directory('dist/')
..pubspec = Pubspec(
'test_app',
version: Version.parse('1.0.0+1'),
);
expect(
makeConfig.outputArtifactPath,
'dist/1.0.0+1/test_app-1.0.0+1-android.apk',
);
});
});
}

0 comments on commit 569a490

Please sign in to comment.