forked from fossasia/pslab-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout_us_screen_version_test.dart
More file actions
88 lines (77 loc) · 2.59 KB
/
Copy pathabout_us_screen_version_test.dart
File metadata and controls
88 lines (77 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:pslab/others/about_us_version_resolver.dart';
void main() {
test('uses package_info_plus version when available', () async {
final version = await resolveAboutUsVersion(
packageInfoLoader: () async => PackageInfo(
appName: 'pslab',
packageName: 'io.pslab',
version: '1.2.3',
buildNumber: '45',
),
isLinux: false,
);
expect(version, '1.2.3+45');
});
test(
'falls back to linux bundle version json when package version is empty',
() async {
final tempDir = await Directory.systemTemp.createTemp(
'pslab-about-version-',
);
addTearDown(() async {
if (await tempDir.exists()) {
await tempDir.delete(recursive: true);
}
});
final executablePath =
'${tempDir.path}${Platform.pathSeparator}bin${Platform.pathSeparator}'
'pslab';
final versionFile = File(
'${tempDir.path}${Platform.pathSeparator}bin${Platform.pathSeparator}'
'data${Platform.pathSeparator}flutter_assets${Platform.pathSeparator}'
'version.json',
);
await versionFile.create(recursive: true);
await versionFile.writeAsString('{"version":"9.8.7"}');
final version = await resolveAboutUsVersion(
packageInfoLoader: () async => PackageInfo(
appName: 'pslab',
packageName: 'io.pslab',
version: '',
buildNumber: '45',
),
isLinux: true,
resolvedExecutable: executablePath,
);
expect(version, '9.8.7+45');
},
);
test('uses version in default path from package', () async {
final executablePath =
'${Platform.pathSeparator}usr${Platform.pathSeparator}bin${Platform.pathSeparator}'
'pslab';
final versionFile = File(
'${Platform.pathSeparator}usr${Platform.pathSeparator}bin${Platform.pathSeparator}'
'data${Platform.pathSeparator}flutter_assets${Platform.pathSeparator}'
'version.json',
);
IOOverrides.runZoned(() async {
await versionFile.create(recursive: true);
await versionFile.writeAsString('{"version":"6.5.3"}');
final version = await resolveAboutUsVersion(
packageInfoLoader: () async => PackageInfo(
appName: 'pslab',
packageName: 'io.pslab',
version: '',
buildNumber: '1234',
),
isLinux: true,
resolvedExecutable: executablePath,
);
expect(version, '6.5.3+1234');
});
});
}