75 lines
2.4 KiB
Dart
75 lines
2.4 KiB
Dart
import 'package:podman/podman.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'support/fake_podman_transport.dart';
|
|
|
|
void main() {
|
|
group('PodmanClient container archive API', () {
|
|
test('supports head/get/put archive endpoints', () async {
|
|
final transport = FakePodmanTransport()
|
|
..enqueue(
|
|
method: HttpMethod.head,
|
|
path: '/v5.0.0/libpod/containers/orchestrator/archive',
|
|
queryParameters: const <String, List<String>>{
|
|
'path': <String>['/etc'],
|
|
},
|
|
statusCode: 200,
|
|
headers: const <String, List<String>>{
|
|
'x-docker-container-path-stat': <String>['stat-head'],
|
|
},
|
|
)
|
|
..enqueue(
|
|
method: HttpMethod.get,
|
|
path: '/v5.0.0/libpod/containers/orchestrator/archive',
|
|
queryParameters: const <String, List<String>>{
|
|
'path': <String>['/etc'],
|
|
'rename': <String>['{"etc":"config"}'],
|
|
},
|
|
statusCode: 200,
|
|
headers: const <String, List<String>>{
|
|
'x-docker-container-path-stat': <String>['stat-get'],
|
|
},
|
|
responseBody: <int>[1, 2, 3, 4],
|
|
)
|
|
..enqueue(
|
|
method: HttpMethod.put,
|
|
path: '/v5.0.0/libpod/containers/orchestrator/archive',
|
|
queryParameters: const <String, List<String>>{
|
|
'path': <String>['/tmp'],
|
|
'copyUIDGID': <String>['false'],
|
|
'noOverwriteDirNonDir': <String>['true'],
|
|
'rename': <String>['{"from":"to"}'],
|
|
},
|
|
body: <int>[65, 66, 67],
|
|
statusCode: 200,
|
|
);
|
|
|
|
final client = PodmanClient(transport: transport);
|
|
|
|
final headStat = await client.headContainerArchive(
|
|
'orchestrator',
|
|
path: '/etc',
|
|
);
|
|
expect(headStat, 'stat-head');
|
|
|
|
final archive = await client.getContainerArchive(
|
|
'orchestrator',
|
|
path: '/etc',
|
|
rename: const <String, String>{'etc': 'config'},
|
|
);
|
|
expect(archive.pathStatHeader, 'stat-get');
|
|
expect(archive.archiveBytes, <int>[1, 2, 3, 4]);
|
|
|
|
await client.putContainerArchive(
|
|
'orchestrator',
|
|
path: '/tmp',
|
|
archiveBytes: const <int>[65, 66, 67],
|
|
copyUidGid: false,
|
|
noOverwriteDirNonDir: true,
|
|
rename: const <String, String>{'from': 'to'},
|
|
);
|
|
|
|
transport.expectNoPending();
|
|
});
|
|
});
|
|
}
|