Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update development dependencies #49

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test("fails with no inputs", async () => {
});

await expect(main()).rejects.toThrow(
"Neither the `packages` nor the `expr` input is given"
"Neither the `packages` nor the `expr` input is given",
);
});

Expand Down Expand Up @@ -61,14 +61,14 @@ test("installs packages into profile", async () => {
"nixpkgs#package2",
"github:yaxitech/ragenix",
],
{ silent: false }
{ silent: false },
);

expect(nix.maybeAddNixpkgs).toHaveBeenCalledTimes(3);
expect(nix.runNix).toHaveBeenCalledTimes(1);
expect(core.setOutput).toHaveBeenCalledWith(
"nix_profile_path",
nixProfileDir
nixProfileDir,
);
expect(core.addPath).toHaveBeenCalledWith(path.join(nixProfileDir, "bin"));
});
Expand Down Expand Up @@ -118,15 +118,15 @@ test("installs expr into profile without inputs-from", async () => {
pkgs = (import nixpkgs { system = "i686-linux"; });
in pkgs.wurzelpfropf`,
],
{ silent: false }
{ silent: false },
);
expect(nix.determineSystem).toHaveBeenCalledTimes(1);
expect(nix.getRepoLockedUrl).toHaveBeenCalledTimes(1);
expect(nix.getNixpkgs).toHaveBeenCalledTimes(1);
expect(nix.runNix).toHaveBeenCalledTimes(1);
expect(core.setOutput).toHaveBeenCalledWith(
"nix_profile_path",
nixProfileDir
nixProfileDir,
);
expect(core.addPath).toHaveBeenCalledWith(path.join(nixProfileDir, "bin"));
});
Expand Down Expand Up @@ -168,7 +168,7 @@ test("installs packages and expr into profile with inputs-from", async () => {

jest.spyOn(nix, "getNixpkgs").mockImplementation(async (_path) => {
expect(_path).toBe(
"file:///nix/store/nyr21fwgx0wzf1j94hd42icc7ffvh8jr-source?narHash=sha256-I4cKCEg3yeO0G4wuA/ohOJPdM2ag1FtqnhwEdsC8PDk="
"file:///nix/store/nyr21fwgx0wzf1j94hd42icc7ffvh8jr-source?narHash=sha256-I4cKCEg3yeO0G4wuA/ohOJPdM2ag1FtqnhwEdsC8PDk=",
);
return `(builtins.getFlake("file:///nix/store/q3ihs6gz300xg08jhvih2w7r50w7nbnn-source?narHash=sha256-KD9fHTbTnbbyG15Bprf43FwrShKfpkFk+p+hSp5wYoU=")).inputs.nixpkgs`;
});
Expand All @@ -190,7 +190,7 @@ test("installs packages and expr into profile with inputs-from", async () => {
"file:///nix/store/nyr21fwgx0wzf1j94hd42icc7ffvh8jr-source?narHash=sha256-I4cKCEg3yeO0G4wuA/ohOJPdM2ag1FtqnhwEdsC8PDk=",
"nixpkgs#wuffmiau",
],
{ silent: false }
{ silent: false },
);

expect(nix.maybeAddNixpkgs).toHaveBeenCalledTimes(1);
Expand All @@ -212,14 +212,14 @@ test("installs packages and expr into profile with inputs-from", async () => {
pkgs = (import nixpkgs { system = "i686-linux"; });
in pkgs.wurzelpfropf`,
],
{ silent: false }
{ silent: false },
);

expect(nix.runNix).toHaveBeenCalledTimes(2);

expect(core.setOutput).toHaveBeenCalledWith(
"nix_profile_path",
nixProfileDir
nixProfileDir,
);
expect(core.addPath).toHaveBeenCalledWith(path.join(nixProfileDir, "bin"));
});
Expand Down
16 changes: 8 additions & 8 deletions __tests__/nix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ afterEach(() => {

test("runNix returns Nix output", () => {
return expect(
nix.runNix(["eval", "--offline", "--expr", '"wurzelpfropf"'])
nix.runNix(["eval", "--offline", "--expr", '"wurzelpfropf"']),
).resolves.toEqual({
stdout: '"wurzelpfropf"\n',
stderr: "",
Expand All @@ -20,13 +20,13 @@ test("runNix returns Nix output", () => {

test("determineSystem() returns system", () => {
return expect(nix.determineSystem()).resolves.toMatch(
/^(aarch64-linux|i686-linux|x86_64-linux|x86_64-darwin|aarch64-darwin)$/
/^(aarch64-linux|i686-linux|x86_64-linux|x86_64-darwin|aarch64-darwin)$/,
);
});

test("maybeAddNixpkgs fails for invalid package", async () => {
await expect(nix.maybeAddNixpkgs("wurzel:pfropf")).rejects.toThrow(
`Given flake reference "wurzel:pfropf" is invalid: error: input 'wurzel:pfropf' is unsupported`
`Given flake reference "wurzel:pfropf" is invalid: error: input 'wurzel:pfropf' is unsupported`,
);
});

Expand All @@ -37,15 +37,15 @@ test("maybeAddNixpkgs adds nixpkgs#", async () => {

test("maybeAddNixpkgs does not add nixpkgs#", async () => {
expect(nix.maybeAddNixpkgs("nixpkgs#wurzelpfropf")).resolves.toBe(
"nixpkgs#wurzelpfropf"
"nixpkgs#wurzelpfropf",
);
expect(nix.maybeAddNixpkgs(".#default")).resolves.toBe(".#default");
expect(nix.maybeAddNixpkgs(".")).resolves.toBe(".");
});

test("maybeAddNixpkgs does not add nixpkgs# [online]", async () => {
expect(nix.maybeAddNixpkgs("github:yaxitech/ragenix")).resolves.toBe(
"github:yaxitech/ragenix"
"github:yaxitech/ragenix",
);
});

Expand Down Expand Up @@ -77,7 +77,7 @@ test("getFlakeLockedUrl fails for invalid flake", async () => {
jest.spyOn(nix, "getFlakeLockedUrl");

await expect(() => nix.getFlakeLockedUrl("doesnotexist")).rejects.toThrow(
/The process '\/.*?\/nix' failed with exit code 1/
/The process '\/.*?\/nix' failed with exit code 1/,
);
expect(nix.getFlakeLockedUrl).toBeCalledTimes(1);
});
Expand All @@ -86,7 +86,7 @@ test("getNixpkgs with inputs-from works", async () => {
const inputsFromLockedUrl = await nix.getRepoLockedUrl(".");
const res = await nix.getNixpkgs(inputsFromLockedUrl);
expect(res).toBe(
`(builtins.getFlake("${inputsFromLockedUrl}")).inputs.nixpkgs`
`(builtins.getFlake("${inputsFromLockedUrl}")).inputs.nixpkgs`,
);
const execRes = await nix.runNix(["eval", "--json", "--expr", res], {
ignoreReturnCode: true,
Expand All @@ -99,7 +99,7 @@ test("getNixpkgs without inputs-from works", async () => {
expect(inputsFromLockedUrl).toBe("");
const res = await nix.getNixpkgs(inputsFromLockedUrl);
expect(res).toMatch(
/^builtins\.getFlake\(\"file:\/\/\/nix\/store\/.*?\?narHash\=.*\"\)$/
/^builtins\.getFlake\(\"file:\/\/\/nix\/store\/.*?\?narHash\=.*\"\)$/,
);
const execRes = await nix.runNix(["eval", "--json", "--expr", res], {
ignoreReturnCode: true,
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

src = self;

npmDepsHash = "sha256-LFSghsG1RJU8kRu/aB3OrLO3gsGsEAh/YnzosKQH1uQ=";
npmDepsHash = "sha256-854rRCAyexvy7eBW1PgDX8YV9oWPrORCDgMov+I7Py0=";

NODE_OPTIONS = "--openssl-legacy-provider";

Expand Down
Loading