mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 14:20:42 +08:00
The node announces the user's own writes, and those of the `rad` CLI, without saying which refs changed, so each one refetched the whole repo, including a scan of every CI job. Comparing the announced signed refs with the previous ones names them. Releases and boards get keys of their own instead of falling back to the whole repo.
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { describe, expect, test } from "vitest";
|
|
|
|
import { keys } from "../src/keys";
|
|
import { affectedKeys } from "../src/refUpdates";
|
|
|
|
const rid = "rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5";
|
|
const nid = "z6MkkfM3tPXNPrPevKr3uSiQtHPuwnNhu2yUVjgd2jXVsVz5";
|
|
const issue = "d87dcfe8c2b3200e78b128d9b959cfdf7063fefe";
|
|
|
|
describe("affectedKeys", () => {
|
|
test("an update without refs affects the whole repository", () => {
|
|
expect(affectedKeys({ rid })).toEqual([keys.repo(rid)]);
|
|
});
|
|
|
|
test("an issue affects itself, the issue list and the repository info", () => {
|
|
expect(
|
|
affectedKeys({
|
|
rid,
|
|
refs: [
|
|
`refs/namespaces/${nid}/refs/cobs/xyz.radicle.issue/${issue}`,
|
|
`refs/namespaces/${nid}/refs/rad/sigrefs`,
|
|
],
|
|
}),
|
|
).toEqual([keys.issue(rid, issue), keys.issues(rid), keys.repoInfo(rid)]);
|
|
});
|
|
|
|
test("branches affect the code and the repository info once", () => {
|
|
expect(
|
|
affectedKeys({
|
|
rid,
|
|
refs: [
|
|
`refs/namespaces/${nid}/refs/heads/main`,
|
|
`refs/namespaces/${nid}/refs/tags/v1.0.0`,
|
|
],
|
|
}),
|
|
).toEqual([keys.code(rid), keys.repoInfo(rid)]);
|
|
});
|
|
|
|
test("a CI job affects the repository's job lists only", () => {
|
|
expect(
|
|
affectedKeys({
|
|
rid,
|
|
refs: [`refs/namespaces/${nid}/refs/cobs/xyz.radworks.job/${issue}`],
|
|
}),
|
|
).toEqual([keys.jobs(rid)]);
|
|
});
|
|
|
|
test("releases and boards affect only their own keys", () => {
|
|
expect(
|
|
affectedKeys({
|
|
rid,
|
|
refs: [
|
|
`refs/namespaces/${nid}/refs/cobs/dev.radicle.artifact/${issue}`,
|
|
`refs/namespaces/${nid}/refs/cobs/works.monadic.board/${issue}`,
|
|
],
|
|
}),
|
|
).toEqual([keys.releases(rid), keys.boards(rid)]);
|
|
});
|
|
|
|
test("an identity update affects the whole repository", () => {
|
|
expect(
|
|
affectedKeys({
|
|
rid,
|
|
refs: [
|
|
`refs/namespaces/${nid}/refs/cobs/xyz.radicle.patch/${issue}`,
|
|
`refs/namespaces/${nid}/refs/rad/id`,
|
|
],
|
|
}),
|
|
).toEqual([keys.repo(rid)]);
|
|
});
|
|
});
|