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 >{ 'images': ['groupware-api:latest', 'groupware-web:latest'], 'all': ['true'], 'annotation': [ 'org.opencontainers.image.title=groupware-stack', ], }, statusCode: 201, responseBody: const {'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 >{ 'tlsVerify': ['true'], }, responseBody: const { 'schemaVersion': 2, 'mediaType': 'application/vnd.oci.image.index.v1+json', 'manifests': [], }, ) ..enqueue( method: HttpMethod.post, path: '/v5.0.0/libpod/manifests/groupware-stack/registry/quay.io%2Fgroupware%2Fstack%3Alatest', queryParameters: const >{ 'all': ['true'], 'quiet': ['true'], 'tlsVerify': ['false'], }, statusCode: 200, responseBody: const {'Id': 'sha256:manifest-digest'}, ) ..enqueue( method: HttpMethod.delete, path: '/v5.0.0/libpod/manifests/groupware-stack', statusCode: 200, responseBody: const { 'Deleted': ['manifest-id-1'], 'Untagged': ['localhost/groupware-stack:latest'], 'ExitCode': 0, 'Errors': [], }, ); final client = PodmanClient(transport: transport); final created = await client.createManifest( 'groupware-stack', options: const ManifestCreateOptions( images: ['groupware-api:latest', 'groupware-web:latest'], all: true, annotations: { '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(); }); }); }