podman/test/podman_client_manifests_test.dart

100 lines
3.4 KiB
Dart

import 'package:podman/podman.dart';
import 'package:test/test.dart';
import 'support/fake_podman_transport.dart';
void main() {
group('PodmanClient manifests API', () {
test('supports create, exists, inspect, push, and delete', () async {
final transport = FakePodmanTransport()
..enqueue(
method: HttpMethod.post,
path: '/v5.0.0/libpod/manifests/groupware-stack',
queryParameters: const <String, List<String>>{
'images': <String>['groupware-api:latest', 'groupware-web:latest'],
'all': <String>['true'],
'annotation': <String>[
'org.opencontainers.image.title=groupware-stack',
],
},
statusCode: 201,
responseBody: const <String, Object?>{'Id': 'manifest-id-1'},
)
..enqueue(
method: HttpMethod.get,
path: '/v5.0.0/libpod/manifests/groupware-stack/exists',
statusCode: 204,
)
..enqueue(
method: HttpMethod.get,
path: '/v5.0.0/libpod/manifests/groupware-stack/json',
queryParameters: const <String, List<String>>{
'tlsVerify': <String>['true'],
},
responseBody: const <String, Object?>{
'schemaVersion': 2,
'mediaType': 'application/vnd.oci.image.index.v1+json',
'manifests': <Object?>[],
},
)
..enqueue(
method: HttpMethod.post,
path:
'/v5.0.0/libpod/manifests/groupware-stack/registry/quay.io%2Fgroupware%2Fstack%3Alatest',
queryParameters: const <String, List<String>>{
'all': <String>['true'],
'quiet': <String>['true'],
'tlsVerify': <String>['false'],
},
statusCode: 200,
responseBody: const <String, Object?>{'Id': 'sha256:manifest-digest'},
)
..enqueue(
method: HttpMethod.delete,
path: '/v5.0.0/libpod/manifests/groupware-stack',
statusCode: 200,
responseBody: const <String, Object?>{
'Deleted': <String>['manifest-id-1'],
'Untagged': <String>['localhost/groupware-stack:latest'],
'ExitCode': 0,
'Errors': <String>[],
},
);
final client = PodmanClient(transport: transport);
final created = await client.createManifest(
'groupware-stack',
options: const ManifestCreateOptions(
images: <String>['groupware-api:latest', 'groupware-web:latest'],
all: true,
annotations: <String, String>{
'org.opencontainers.image.title': 'groupware-stack',
},
),
);
expect(created.id, 'manifest-id-1');
final exists = await client.manifestExists('groupware-stack');
expect(exists, isTrue);
final details = await client.inspectManifest(
'groupware-stack',
tlsVerify: true,
);
expect(details.schemaVersion, 2);
expect(details.mediaType, 'application/vnd.oci.image.index.v1+json');
final pushed = await client.pushManifest(
'groupware-stack',
'quay.io/groupware/stack:latest',
tlsVerify: false,
);
expect(pushed.id, 'sha256:manifest-digest');
final deleted = await client.deleteManifest('groupware-stack');
expect(deleted.deleted, contains('manifest-id-1'));
transport.expectNoPending();
});
});
}