mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Check bare RIDs against already seeded repos
The seed form accepts a RID without the rad: prefix but compared it as typed against lists that have the prefix, so duplicates got through.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { seedTarget } from "@app/lib/seedRepo";
|
||||
|
||||
const rid = "rad:z3fpY7nttPPa6MBnAv2DccHzQJnqe";
|
||||
const bare = "z3fpY7nttPPa6MBnAv2DccHzQJnqe";
|
||||
|
||||
describe("seedTarget", () => {
|
||||
test.each([rid, bare, ` ${rid} `])("accepts %j as %j", input => {
|
||||
expect(seedTarget(input, [], [])).toEqual({ rid });
|
||||
});
|
||||
|
||||
test.each(["", "rad:", "rad:z0OIl", "not a rid", "rad:zabc"])(
|
||||
"rejects %j",
|
||||
input => {
|
||||
expect(seedTarget(input, [], [])).toEqual({ error: "RID is not valid" });
|
||||
},
|
||||
);
|
||||
|
||||
test.each([rid, bare])("reports %j as already queued", input => {
|
||||
expect(seedTarget(input, [rid], [])).toEqual({
|
||||
error: "This repo is already queued for fetching",
|
||||
});
|
||||
});
|
||||
|
||||
test.each([rid, bare])("reports %j as already seeded", input => {
|
||||
expect(seedTarget(input, [], [rid])).toEqual({
|
||||
error: "This repo is already seeded",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user