Skip to content

Commit 2233e8f

Browse files
committed
chore: Update to latest snapd client
1 parent 0e2f15d commit 2233e8f

20 files changed

+310
-134
lines changed

packages/app_center/lib/snapd/snap_data.freezed.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ abstract class $SnapDataCopyWith<$Res> {
7676
Snap? storeSnap,
7777
String? selectedChannel,
7878
String? activeChangeId});
79+
80+
$SnapCopyWith<$Res>? get localSnap;
81+
$SnapCopyWith<$Res>? get storeSnap;
7982
}
8083

8184
/// @nodoc
@@ -120,6 +123,30 @@ class _$SnapDataCopyWithImpl<$Res, $Val extends SnapData>
120123
as String?,
121124
) as $Val);
122125
}
126+
127+
@override
128+
@pragma('vm:prefer-inline')
129+
$SnapCopyWith<$Res>? get localSnap {
130+
if (_value.localSnap == null) {
131+
return null;
132+
}
133+
134+
return $SnapCopyWith<$Res>(_value.localSnap!, (value) {
135+
return _then(_value.copyWith(localSnap: value) as $Val);
136+
});
137+
}
138+
139+
@override
140+
@pragma('vm:prefer-inline')
141+
$SnapCopyWith<$Res>? get storeSnap {
142+
if (_value.storeSnap == null) {
143+
return null;
144+
}
145+
146+
return $SnapCopyWith<$Res>(_value.storeSnap!, (value) {
147+
return _then(_value.copyWith(storeSnap: value) as $Val);
148+
});
149+
}
123150
}
124151

125152
/// @nodoc
@@ -136,6 +163,11 @@ abstract class _$$SnapDataImplCopyWith<$Res>
136163
Snap? storeSnap,
137164
String? selectedChannel,
138165
String? activeChangeId});
166+
167+
@override
168+
$SnapCopyWith<$Res>? get localSnap;
169+
@override
170+
$SnapCopyWith<$Res>? get storeSnap;
139171
}
140172

141173
/// @nodoc

packages/app_center/lib/snapd/snap_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class _SnapView extends StatelessWidget {
109109
children: [
110110
if (snapData.snap.website?.isNotEmpty ?? false)
111111
'<a href="${snapData.snap.website}">${l10n.snapPageDeveloperWebsiteLabel}</a>',
112-
if ((snapData.snap.contact?.isNotEmpty ?? false) &&
112+
if ((snapData.snap.contact.isNotEmpty) &&
113113
snapData.snap.publisher != null)
114114
'<a href="${snapData.snap.contact}">${l10n.snapPageContactPublisherLabel(snapData.snap.publisher!.displayName)}</a>',
115115
]
@@ -649,7 +649,7 @@ class _ChannelDropdownEntry extends StatelessWidget {
649649
channelEntry.key,
650650
channelEntry.value.version,
651651
DateFormat.yMd().format(channelEntry.value.releasedAt),
652-
].map((e) => Text(e, maxLines: 1)).toList(),
652+
].nonNulls.map((e) => Text(e, maxLines: 1)).toList(),
653653
),
654654
),
655655
],

packages/app_center/pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ dependencies:
4040
riverpod_annotation: ^2.3.5
4141
shimmer: ^3.0.0
4242
snapcraft_launcher: ^0.1.0
43-
snapd: ^0.4.14
43+
snapd:
44+
git:
45+
url: https://github.com/spydon/snapd.dart
46+
ref: refactor/use-freezed
4447
snowball_stemmer: ^0.1.0
4548
ubuntu_localizations: ^0.3.6
4649
ubuntu_logger: ^0.1.1

packages/app_center/test/app_card_test.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:app_center/widgets/widgets.dart';
22
import 'package:app_center_ratings_client/app_center_ratings_client.dart';
33
import 'package:flutter_riverpod/flutter_riverpod.dart';
44
import 'package:flutter_test/flutter_test.dart';
5-
import 'package:snapd/snapd.dart';
65
import 'package:ubuntu_service/ubuntu_service.dart';
76

87
import 'test_utils.dart';
@@ -14,10 +13,17 @@ const snapRating = Rating(
1413
ratingsBand: RatingsBand.good,
1514
);
1615

17-
const snap = Snap(
16+
final snap = createSnap(
1817
name: 'testsnap',
1918
id: 'r4LxMVp7zWramXsJQAKdamxy6TAWlaDD',
2019
summary: 'Its a summary!',
20+
revision: '',
21+
version: '',
22+
channel: '',
23+
base: '',
24+
contact: '',
25+
description: '',
26+
type: '',
2127
);
2228

2329
void main() {

packages/app_center/test/games_page_test.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,36 @@ void main() {
2222
tearDown(resetAllServices);
2323

2424
final mockSearchProvider = createMockSnapSearchProvider({
25-
const SnapSearchParameters(query: 'testsn'): const [
26-
Snap(name: 'testsnap', title: 'Test Snap', downloadSize: 3),
27-
Snap(name: 'testsnap2', title: 'Another Test Snap', downloadSize: 1),
28-
Snap(name: 'testsnap3', title: 'Yet Another Test Snap', downloadSize: 2),
25+
const SnapSearchParameters(query: 'testsn'): [
26+
createSnap(name: 'testsnap', title: 'Test Snap', downloadSize: 3),
27+
createSnap(
28+
name: 'testsnap2', title: 'Another Test Snap', downloadSize: 1),
29+
createSnap(
30+
name: 'testsnap3', title: 'Yet Another Test Snap', downloadSize: 2),
2931
],
3032
const SnapSearchParameters(
3133
category: SnapCategoryEnum.games,
32-
): const [
33-
Snap(
34+
): [
35+
createSnap(
3436
name: 'testsnap4',
3537
title: 'A Cool Game',
3638
summary: 'This is a really cool game',
3739
downloadSize: 2,
3840
media: [
39-
SnapMedia(type: 'screenshot', url: 'https://example.com'),
41+
const SnapMedia(type: 'screenshot', url: 'https://example.com'),
4042
],
4143
),
42-
Snap(
44+
createSnap(
4345
name: 'testsnap5',
4446
summary: 'This is another really cool game',
4547
downloadSize: 3,
4648
media: [
47-
SnapMedia(type: 'screenshot', url: 'https://example.com'),
49+
const SnapMedia(type: 'screenshot', url: 'https://example.com'),
4850
],
4951
),
5052
],
51-
const SnapSearchParameters(category: SnapCategoryEnum.education): const [
52-
Snap(name: 'educational-snap', title: 'Educational Snap'),
53+
const SnapSearchParameters(category: SnapCategoryEnum.education): [
54+
createSnap(name: 'educational-snap', title: 'Educational Snap'),
5355
],
5456
});
5557

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import 'package:app_center/manage/manage_model.dart';
22
import 'package:flutter_test/flutter_test.dart';
3-
import 'package:snapd/snapd.dart';
43

54
import 'test_utils.dart';
65

76
void main() {
87
test('no updates available', () async {
98
final snapd = registerMockSnapdService(
10-
installedSnaps: const [Snap(name: 'firefox'), Snap(name: 'thunderbird')],
9+
installedSnaps: [
10+
createSnap(name: 'firefox'),
11+
createSnap(name: 'thunderbird')
12+
],
1113
);
1214
final updatesModel = createMockUpdatesModel();
1315
final model = ManageModel(snapd: snapd, updatesModel: updatesModel);
1416
await model.init();
1517

1618
expect(
1719
model.nonRefreshableSnaps,
18-
equals(const [Snap(name: 'firefox'), Snap(name: 'thunderbird')]),
20+
equals([createSnap(name: 'firefox'), createSnap(name: 'thunderbird')]),
1921
);
2022
expect(model.refreshableSnaps, isEmpty);
2123
});
2224
test('update available', () async {
2325
final snapd = registerMockSnapdService(
24-
installedSnaps: const [Snap(name: 'firefox'), Snap(name: 'thunderbird')],
26+
installedSnaps: [
27+
createSnap(name: 'firefox'),
28+
createSnap(name: 'thunderbird')
29+
],
2530
);
2631
final updatesModel =
2732
createMockUpdatesModel(refreshableSnapNames: ['firefox']);
@@ -30,8 +35,11 @@ void main() {
3035

3136
expect(
3237
model.nonRefreshableSnaps,
33-
equals(const [Snap(name: 'thunderbird')]),
38+
equals([createSnap(name: 'thunderbird')]),
39+
);
40+
expect(
41+
model.refreshableSnaps,
42+
equals([createSnap(name: 'firefox')]),
3443
);
35-
expect(model.refreshableSnaps, equals(const [Snap(name: 'firefox')]));
3644
});
3745
}

packages/app_center/test/manage_page_test.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ import 'package:yaru_test/yaru_test.dart';
1515
import 'test_utils.dart';
1616

1717
void main() {
18-
const nonRefreshableSnaps = [
19-
Snap(
18+
final nonRefreshableSnaps = [
19+
createSnap(
2020
name: 'testsnap',
2121
title: 'Test Snap',
2222
version: '1.0',
2323
channel: 'latest/stable',
2424
),
25-
Snap(
25+
createSnap(
2626
name: 'testsnap2',
2727
title: 'Another Test Snap',
2828
version: '1.5',
2929
channel: 'latest/candidate',
3030
),
3131
];
3232
final refreshableSnaps = [
33-
Snap(
33+
createSnap(
3434
name: 'testsnap3',
3535
title: 'Snap with an update',
3636
version: '2.0',
@@ -240,9 +240,12 @@ void main() {
240240
isBusy: true,
241241
);
242242
final mockChange = SnapdChange(
243+
id: '',
243244
spawnTime: DateTime(1970),
244245
kind: 'refresh-snap',
245-
tasks: [SnapdTask(progress: const SnapdTaskProgress(done: 1, total: 4))],
246+
tasks: [
247+
const SnapdTask(id: '', progress: SnapdTaskProgress(done: 1, total: 4)),
248+
],
246249
);
247250
await tester.pumpApp(
248251
(_) => ProviderScope(
@@ -298,7 +301,7 @@ void main() {
298301
),
299302
),
300303
activeChangeProvider.overrideWith(
301-
(_, __) => SnapdChange(spawnTime: DateTime(1970)),
304+
(_, __) => SnapdChange(id: '', spawnTime: DateTime(1970)),
302305
),
303306
updatesModelProvider.overrideWith((_) => mockUpdatesModel),
304307
],

packages/app_center/test/multisnap_model_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import 'package:snapd/snapd.dart';
66

77
import 'test_utils.dart';
88

9-
final storeSnap = Snap(
9+
final storeSnap = createSnap(
1010
name: 'testsnap',
1111
title: 'Testsnap',
12-
publisher: const SnapPublisher(displayName: 'testPublisher'),
12+
publisher: const SnapPublisher(id: '', displayName: 'testPublisher'),
1313
version: '1.0.0',
1414
website: 'https://example.com',
1515
confinement: SnapConfinement.strict,

packages/app_center/test/ratings_model_test.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import 'package:app_center_ratings_client/app_center_ratings_client.dart';
33
import 'package:clock/clock.dart';
44
import 'package:flutter_test/flutter_test.dart';
55
import 'package:mockito/mockito.dart';
6-
import 'package:snapd/snapd.dart';
76
import 'package:ubuntu_service/ubuntu_service.dart';
87

98
import 'test_utils.dart';
109

1110
void main() {
12-
const snap = Snap(
11+
final snap = createSnap(
1312
name: 'firefox',
1413
id: 'firefox',
1514
revision: '42',

packages/app_center/test/search_field_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
66
import 'package:flutter_riverpod/flutter_riverpod.dart';
77
import 'package:flutter_test/flutter_test.dart';
88
import 'package:mockito/mockito.dart';
9-
import 'package:snapd/snapd.dart';
109

1110
import 'test_utils.dart';
1211

@@ -18,10 +17,10 @@ class MockStringCallback extends Mock implements StringCallback {}
1817

1918
void main() {
2019
final mockSnapSearchProvider = createMockSnapSearchProvider({
21-
const SnapSearchParameters(query: 'testsn'): const [
22-
Snap(name: 'testsnap', title: 'Test Snap'),
23-
Snap(name: 'testsnap2', title: 'Another Test Snap'),
24-
],
20+
const SnapSearchParameters(query: 'testsn'): [
21+
createSnap(name: 'testsnap', title: 'Test Snap'),
22+
createSnap(name: 'testsnap2', title: 'Another Test Snap'),
23+
]
2524
});
2625

2726
final mockDebSearchProvider = createMockDebSearchProvider({

0 commit comments

Comments
 (0)