Initial Dockge image update checker
All checks were successful
Build / test (push) Successful in 14s

This commit is contained in:
MrSphay
2026-05-14 17:35:56 +02:00
commit 0e0a21f508
18 changed files with 869 additions and 0 deletions

28
test/image-ref.test.js Normal file
View File

@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { digestMatchesRepoDigests, parseImageRef } from "../src/image-ref.js";
test("parses Docker Hub shorthand image references", () => {
assert.deepEqual(parseImageRef("nginx:1.27"), {
original: "nginx:1.27",
registry: "registry-1.docker.io",
repository: "library/nginx",
tag: "1.27",
registryRef: "registry-1.docker.io/library/nginx:1.27",
repositoryRef: "registry-1.docker.io/library/nginx",
});
});
test("parses custom registry image references", () => {
assert.deepEqual(parseImageRef("ghcr.io/example/app:main").registryRef, "ghcr.io/example/app:main");
});
test("defaults missing tags to latest", () => {
assert.equal(parseImageRef("redis").tag, "latest");
});
test("matches remote digests against repo digests", () => {
const imageRef = parseImageRef("nginx:latest");
assert.equal(digestMatchesRepoDigests("sha256:abc", ["registry-1.docker.io/library/nginx@sha256:abc"], imageRef), true);
assert.equal(digestMatchesRepoDigests("sha256:def", ["registry-1.docker.io/library/nginx@sha256:abc"], imageRef), false);
});