release: r016 fix Docker update cache matching
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/unraid-mcp-status-helper.php';
|
||||
|
||||
function expect_same(string $label, mixed $expected, mixed $actual): void {
|
||||
if ($expected === $actual) {
|
||||
echo "PASS: $label\n";
|
||||
return;
|
||||
}
|
||||
fwrite(STDERR, "FAIL: $label\nExpected: " . json_encode($expected) . "\nActual: " . json_encode($actual) . "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$native = [
|
||||
'Windows11' => 'false',
|
||||
'WindowsXP' => false,
|
||||
'AirConnect' => ['status' => 'true'],
|
||||
];
|
||||
expect_same('native container-name key', 'update-available', docker_update_state($native, 'Windows11', 'dockurr/windows'));
|
||||
expect_same('boolean false is an update', 'update-available', docker_update_state($native, 'WindowsXP', 'dockurr/windows'));
|
||||
expect_same('object status is understood', 'up-to-date', docker_update_state($native, 'AirConnect', '1activegeek/airconnect:latest'));
|
||||
|
||||
$legacy = [
|
||||
'library/redis:latest' => ['status' => 'false'],
|
||||
'dockurr/windows:latest' => ['updated' => true],
|
||||
];
|
||||
expect_same('Docker Hub library alias', 'update-available', docker_update_state($legacy, 'Redis', 'redis'));
|
||||
expect_same('implicit latest tag', 'up-to-date', docker_update_state($legacy, 'Windows11', 'dockurr/windows'));
|
||||
|
||||
$list = [
|
||||
['container' => 'Virtual-DSM', 'image' => 'vdsm/virtual-dsm:latest', 'updateAvailable' => true],
|
||||
];
|
||||
expect_same('list format with updateAvailable', 'update-available', docker_update_state($list, 'Virtual-DSM', 'vdsm/virtual-dsm:latest'));
|
||||
|
||||
$summary = docker_update_status_from(
|
||||
['Windows11' => 'false', 'AirConnect' => 'true'],
|
||||
['Windows11|dockurr/windows', 'AirConnect|1activegeek/airconnect:latest', 'Mystery|example/mystery'],
|
||||
);
|
||||
expect_same('known update count', 1, $summary['updates_available']);
|
||||
expect_same('unknown count', 1, $summary['unknown_count']);
|
||||
expect_same('incomplete cache is explicit', false, $summary['status_complete']);
|
||||
expect_same('reported count marked as minimum', true, $summary['updates_available_is_minimum']);
|
||||
|
||||
echo "All Docker update cache tests passed.\n";
|
||||
Reference in New Issue
Block a user