Initial Dockge image update checker
All checks were successful
Build / test (push) Successful in 14s
All checks were successful
Build / test (push) Successful in 14s
This commit is contained in:
28
test/image-ref.test.js
Normal file
28
test/image-ref.test.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user