@@ -21,12 +21,15 @@ const emptyResponseBody = '{}';
21
21
22
22
const command = ['dart' , 'pub' , 'global' , 'activate' , 'very_good_cli' ];
23
23
24
+ const customBaseUrl = 'https://custom-domain.com/api/packages/' ;
25
+
24
26
void main () {
25
27
group ('PubUpdater' , () {
26
28
late Client client;
27
29
late Response response;
28
30
late PubUpdater pubUpdater;
29
31
late ProcessManager processManager;
32
+
30
33
setUpAll (() {
31
34
registerFallbackValue (Uri ());
32
35
});
@@ -49,6 +52,10 @@ void main() {
49
52
expect (PubUpdater (), isNotNull);
50
53
});
51
54
55
+ test ('can be instantiated with a custom base url' , () {
56
+ expect (PubUpdater (null , customBaseUrl), isNotNull);
57
+ });
58
+
52
59
group ('isUpToDate' , () {
53
60
test ('makes correct http request' , () async {
54
61
when (() => response.body).thenReturn (emptyResponseBody);
@@ -70,6 +77,24 @@ void main() {
70
77
).called (1 );
71
78
});
72
79
80
+ test ('makes correct http request with a custom base url' , () async {
81
+ when (() => response.body).thenReturn (emptyResponseBody);
82
+ pubUpdater = PubUpdater (client, customBaseUrl);
83
+
84
+ try {
85
+ await pubUpdater.isUpToDate (
86
+ packageName: 'very_good_cli' ,
87
+ currentVersion: '0.3.3' ,
88
+ );
89
+ } catch (_) {}
90
+
91
+ verify (
92
+ () => client.get (
93
+ Uri .parse ('${customBaseUrl }very_good_cli' ),
94
+ ),
95
+ ).called (1 );
96
+ });
97
+
73
98
test ('returns false when currentVersion < latestVersion' , () async {
74
99
expect (
75
100
await pubUpdater.isUpToDate (
@@ -132,6 +157,21 @@ void main() {
132
157
).called (1 );
133
158
});
134
159
160
+ test ('makes correct http request with a custom base url' , () async {
161
+ when (() => response.body).thenReturn (emptyResponseBody);
162
+ pubUpdater = PubUpdater (client, customBaseUrl);
163
+
164
+ try {
165
+ await pubUpdater.getLatestVersion ('very_good_cli' );
166
+ } catch (_) {}
167
+
168
+ verify (
169
+ () => client.get (
170
+ Uri .parse ('${customBaseUrl }very_good_cli' ),
171
+ ),
172
+ ).called (1 );
173
+ });
174
+
135
175
test ('returns correct version' , () async {
136
176
when (() => response.body).thenReturn (validPackageInfoResponseBody);
137
177
expect (
0 commit comments