1117
test_install_needs_classic ()
1119
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1120
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1121
mock_snap_set_confinement (s, "classic");
1123
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1124
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1125
connectRequest->runSync ();
1126
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1128
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1129
QScopedPointer<QSnapdInstallRequest> installRequest (client.install ("snap"));
1130
installRequest->runSync ();
1131
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NeedsClassic);
1135
test_install_classic ()
1137
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1138
mock_snapd_set_on_classic (snapd, TRUE);
1139
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1140
mock_snap_set_confinement (s, "classic");
1142
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1143
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1144
connectRequest->runSync ();
1145
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1147
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1148
QScopedPointer<QSnapdInstallRequest> installRequest (client.install (QSnapdClient::Classic, "snap"));
1149
installRequest->runSync ();
1150
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NoError);
1151
g_assert (mock_snapd_find_snap (snapd, "snap") != NULL);
1152
g_assert_cmpstr (mock_snapd_find_snap (snapd, "snap")->confinement, ==, "classic");
1156
test_install_needs_classic_system ()
1158
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1159
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1160
mock_snap_set_confinement (s, "classic");
1162
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1163
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1164
connectRequest->runSync ();
1165
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1167
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1168
QScopedPointer<QSnapdInstallRequest> installRequest (client.install (QSnapdClient::Classic, "snap"));
1169
installRequest->runSync ();
1170
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NeedsClassicSystem);
1174
test_install_needs_devmode ()
1176
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1177
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1178
mock_snap_set_confinement (s, "devmode");
1180
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1181
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1182
connectRequest->runSync ();
1183
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1185
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1186
QScopedPointer<QSnapdInstallRequest> installRequest (client.install ("snap"));
1187
installRequest->runSync ();
1188
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NeedsDevmode);
1192
test_install_devmode ()
1194
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1195
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1196
mock_snap_set_confinement (s, "devmode");
1198
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1199
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1200
connectRequest->runSync ();
1201
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1203
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1204
QScopedPointer<QSnapdInstallRequest> installRequest (client.install (QSnapdClient::Devmode, "snap"));
1205
installRequest->runSync ();
1206
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NoError);
1207
g_assert (mock_snapd_find_snap (snapd, "snap") != NULL);
1208
g_assert (mock_snapd_find_snap (snapd, "snap")->devmode);
1212
test_install_dangerous ()
1214
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1215
mock_snapd_add_store_snap (snapd, "snap");
1217
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1218
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1219
connectRequest->runSync ();
1220
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1222
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1223
QScopedPointer<QSnapdInstallRequest> installRequest (client.install (QSnapdClient::Dangerous, "snap"));
1224
installRequest->runSync ();
1225
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NoError);
1226
g_assert (mock_snapd_find_snap (snapd, "snap") != NULL);
1227
g_assert (mock_snapd_find_snap (snapd, "snap")->dangerous);
1231
test_install_jailmode ()
1233
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1234
mock_snapd_add_store_snap (snapd, "snap");
1236
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1237
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1238
connectRequest->runSync ();
1239
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1241
g_assert (mock_snapd_find_snap (snapd, "snap") == NULL);
1242
QScopedPointer<QSnapdInstallRequest> installRequest (client.install (QSnapdClient::Jailmode, "snap"));
1243
installRequest->runSync ();
1244
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NoError);
1245
g_assert (mock_snapd_find_snap (snapd, "snap") != NULL);
1246
g_assert (mock_snapd_find_snap (snapd, "snap")->jailmode);
1113
1250
test_install_channel ()
1115
1252
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1271
test_install_revision ()
1273
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
1274
MockSnap *s = mock_snapd_add_store_snap (snapd, "snap");
1275
mock_snap_set_revision (s, "1.2");
1276
s = mock_snapd_add_store_snap (snapd, "snap");
1277
mock_snap_set_revision (s, "1.1");
1279
QSnapdClient client (g_socket_get_fd (mock_snapd_get_client_socket (snapd)));
1280
QScopedPointer<QSnapdConnectRequest> connectRequest (client.connect ());
1281
connectRequest->runSync ();
1282
g_assert_cmpint (connectRequest->error (), ==, QSnapdRequest::NoError);
1284
QScopedPointer<QSnapdInstallRequest> installRequest (client.install ("snap", NULL, "1.1"));
1285
installRequest->runSync ();
1286
g_assert_cmpint (installRequest->error (), ==, QSnapdRequest::NoError);
1287
g_assert (mock_snapd_find_snap (snapd, "snap") != NULL);
1288
g_assert_cmpstr (mock_snapd_find_snap (snapd, "snap")->revision, ==, "1.1");
1134
1292
test_install_not_available ()
1136
1294
g_autoptr(MockSnapd) snapd = mock_snapd_new ();
2209
2367
g_test_add_func ("/find-refreshable/no-updates", test_find_refreshable_no_updates);
2210
2368
g_test_add_func ("/install/basic", test_install);
2211
2369
g_test_add_func ("/install/progress", test_install_progress);
2370
g_test_add_func ("/install/needs-classic", test_install_needs_classic);
2371
g_test_add_func ("/install/classic", test_install_classic);
2372
g_test_add_func ("/install/needs-classic-system", test_install_needs_classic_system);
2373
g_test_add_func ("/install/needs-devmode", test_install_needs_devmode);
2374
g_test_add_func ("/install/devmode", test_install_devmode);
2375
g_test_add_func ("/install/dangerous", test_install_dangerous);
2376
g_test_add_func ("/install/jailmode", test_install_jailmode);
2212
2377
g_test_add_func ("/install/channel", test_install_channel);
2378
g_test_add_func ("/install/revision", test_install_revision);
2213
2379
g_test_add_func ("/install/not-available", test_install_not_available);
2214
2380
g_test_add_func ("/install-stream/basic", test_install_stream);
2215
2381
g_test_add_func ("/install-stream/progress", test_install_stream_progress);