39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:podman/podman.dart';
|
|
|
|
const String localBackendValue = 'local';
|
|
|
|
const String _backendEnvKey = 'PODMAN_TEST_BACKEND';
|
|
const String _localFlagEnvKey = 'PODMAN_LOCAL_TESTS';
|
|
const String _socketEnvKey = 'PODMAN_TEST_SOCKET';
|
|
|
|
/// Whether tests should run against a real Podman socket.
|
|
bool get useLocalPodmanTests {
|
|
final backend = Platform.environment[_backendEnvKey];
|
|
if (backend != null && backend.isNotEmpty) {
|
|
return backend.toLowerCase() == localBackendValue;
|
|
}
|
|
|
|
final flag = Platform.environment[_localFlagEnvKey];
|
|
if (flag == null || flag.isEmpty) {
|
|
return false;
|
|
}
|
|
|
|
final normalized = flag.toLowerCase();
|
|
return normalized == '1' || normalized == 'true' || normalized == 'yes';
|
|
}
|
|
|
|
/// Skip reason shown when local tests are disabled.
|
|
String get localTestsSkipReason =>
|
|
'Set $_backendEnvKey=$localBackendValue (or $_localFlagEnvKey=1) '
|
|
'to run local Podman integration tests.';
|
|
|
|
/// Creates a client for local Podman tests.
|
|
PodmanClient createLocalTestClient() {
|
|
final socketPath = Platform.environment[_socketEnvKey];
|
|
if (socketPath != null && socketPath.isNotEmpty) {
|
|
return PodmanClient(socketPath: socketPath);
|
|
}
|
|
return PodmanClient();
|
|
}
|