Skip to content

Commit

Permalink
Update deps (#170)
Browse files Browse the repository at this point in the history
* Update dependencies

* update test deps

* update test file

* fix tests

* fix tests
  • Loading branch information
ebebbington authored Aug 13, 2023
1 parent 1fb4e17 commit 9cd6b0b
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 104 deletions.
4 changes: 2 additions & 2 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export * as Line from "https://deno.land/x/[email protected]/mod.ts";
import { ConsoleLogger } from "https://deno.land/x/[email protected]/mod.ts";
const consoleLogger = new ConsoleLogger({});
export { consoleLogger as ConsoleLogger };
export { assertEquals } from "https://deno.land/std@0.168.0/testing/asserts.ts";
export * as colours from "https://deno.land/std@0.168.0/fmt/colors.ts";
export { assertEquals } from "https://deno.land/std@0.196.0/testing/asserts.ts";
export * as colours from "https://deno.land/std@0.196.0/fmt/colors.ts";
46 changes: 21 additions & 25 deletions tests/integration/error_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ import { expectedHelpMessage } from "../data/expected_help_message.ts";
Deno.test({
name: "No Purpose",
async fn(): Promise<void> {
const p = await Deno.run({
cmd: ["deno", "run", "--allow-net", "--allow-read", "../../../mod.ts"],
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"--allow-read",
"../../../mod.ts",
],
cwd: upToDateDepsDir,
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(
stdout,
out,
expectedHelpMessage,
);
assertEquals(stderr, "");
assertEquals(status.code, 0);
assertEquals(status.success, true);
assertEquals(err, "");
assertEquals(code, 0);
},
});

Deno.test({
name: "Purpose is Not Supported",
async fn(): Promise<void> {
const p = await Deno.run({
cmd: [
"deno",
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"--allow-read",
Expand All @@ -43,19 +43,15 @@ Deno.test({
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(
stdout,
out,
colours.red("[ERROR] ") +
"Command 'dmm' used incorrectly. Error(s) found:\n\n * Unknown argument(s) provided: something.\n\nUSAGE\n\n dmm [option]\n dmm [subcommand]\n\n Run `dmm --help` for more information.\n",
);
assertEquals(stderr, "");
assertEquals(status.code, 1);
assertEquals(status.success, false);
assertEquals(err, "");
assertEquals(code, 1);
},
});
25 changes: 13 additions & 12 deletions tests/integration/help_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import { expectedHelpMessage } from "../data/expected_help_message.ts";
Deno.test({
name: "Should display the help text",
async fn(): Promise<void> {
const p = await Deno.run({
cmd: ["deno", "run", "--allow-net", "../../../mod.ts", "--help"],
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"../../../mod.ts",
"--help",
],
cwd: upToDateDepsDir,
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
assertEquals(stderr, "");
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(err, "");
assertEquals(
stdout,
out,
expectedHelpMessage,
);
assertEquals(status.code, 0);
assertEquals(status.success, true);
assertEquals(code, 0);
},
});
12 changes: 6 additions & 6 deletions tests/integration/up-to-date-deps/deps.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Drash } from "https://deno.land/x/[email protected]/mod.ts"; // up to date

import * as fs from "https://deno.land/std@0.168.0/fs/mod.ts"; // up to date
import * as fs from "https://deno.land/std@0.198.0/fs/mod.ts"; // up to date

import * as colors from "https://deno.land/std@0.168.0/fmt/colors.ts"; //up to date
import * as colors from "https://deno.land/std@0.198.0/fmt/colors.ts"; //up to date

import * as Cliffy from "https://x.nest.land/[email protected]/mod.ts"; //up to date

import * as log from "https://deno.land/std@0.168.0/log/mod.ts"; //up to date
import * as log from "https://deno.land/std@0.198.0/log/mod.ts"; //up to date

export { v4 } from "https://deno.land/std@0.168.0/uuid/mod.ts"; //up to date
export { v4 } from "https://deno.land/std@0.198.0/uuid/mod.ts"; //up to date

export { Cliffy, colors, Drash, fs, log };

export { Something } from "https://raw.githubusercontent.com/drashland/wocket/v1.0.0/mod.ts";

export { createBot } from "https://deno.land/x/discordeno@17.0.1/mod.ts";
export { createBot } from "https://deno.land/x/discordeno@18.0.1/mod.ts";

import _Table from "https://unpkg.com/[email protected].0/dist/index.mjs";
import _Table from "https://unpkg.com/[email protected].2/dist/index.mjs";
12 changes: 6 additions & 6 deletions tests/integration/up-to-date-deps/original_deps.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Drash } from "https://deno.land/x/[email protected]/mod.ts"; // up to date

import * as fs from "https://deno.land/std@0.168.0/fs/mod.ts"; // up to date
import * as fs from "https://deno.land/std@0.198.0/fs/mod.ts"; // up to date

import * as colors from "https://deno.land/std@0.168.0/fmt/colors.ts"; //up to date
import * as colors from "https://deno.land/std@0.198.0/fmt/colors.ts"; //up to date

import * as Cliffy from "https://x.nest.land/[email protected]/mod.ts"; //up to date

import * as log from "https://deno.land/std@0.168.0/log/mod.ts"; //up to date
import * as log from "https://deno.land/std@0.198.0/log/mod.ts"; //up to date

export { v4 } from "https://deno.land/std@0.168.0/uuid/mod.ts"; //up to date
export { v4 } from "https://deno.land/std@0.198.0/uuid/mod.ts"; //up to date

export { Cliffy, colors, Drash, fs, log };

export { Something } from "https://raw.githubusercontent.com/drashland/wocket/v1.0.0/mod.ts";

export { createBot } from "https://deno.land/x/discordeno@17.0.1/mod.ts";
export { createBot } from "https://deno.land/x/discordeno@18.0.1/mod.ts";

import _Table from "https://unpkg.com/[email protected].0/dist/index.mjs";
import _Table from "https://unpkg.com/[email protected].2/dist/index.mjs";
66 changes: 26 additions & 40 deletions tests/integration/update_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,23 @@ Deno.test({
async fn(): Promise<void> {
defaultDepsBackToOriginal("out-of-date-deps");
try {
const p = await Deno.run({
cmd: [
"deno",
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"--allow-read",
"--allow-write",
"../../../mod.ts",
"update",
],

cwd: outOfDateDepsDir,
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
const assertedOutput = colours.green("[INFO]") +
" Gathering information on your dependencies...\n" +
colours.green("[INFO]") +
Expand All @@ -88,10 +85,9 @@ Deno.test({
` discordeno was updated from 13.0.0-rc34 to ${latestDiscordDenoRelease}\n` +
colours.green("[INFO]") +
` table-layout was updated from 2.0.0 to ${latestTableLayoutRelease}\n`;
assertEquals(stdout, assertedOutput);
assertEquals(stderr, "");
assertEquals(status.code, 0);
assertEquals(status.success, true);
assertEquals(out, assertedOutput);
assertEquals(err, "");
assertEquals(code, 0);
const originalDepContent = new TextDecoder("utf-8").decode(
Deno.readFileSync(outOfDateOriginalDepsFile),
);
Expand Down Expand Up @@ -122,9 +118,8 @@ Deno.test({
Deno.test({
name: "Should be OK if no modules need to be updated",
async fn(): Promise<void> {
const p = await Deno.run({
cmd: [
"deno",
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"--allow-read",
Expand All @@ -136,40 +131,35 @@ Deno.test({
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(
stdout,
out,
colours.green("[INFO]") +
" Gathering information on your dependencies...\n" +
colours.green("[INFO]") +
" Checking if your modules can be updated...\n" +
colours.green("[INFO]") + " Everything is already up to date\n",
);
assertEquals(stderr, "");
assertEquals(status.code, 0);
assertEquals(status.success, true);
assertEquals(err, "");
assertEquals(code, 0);
const originalDepContent = new TextDecoder("utf-8").decode(
Deno.readFileSync(upToDateOriginalDepsFile),
);
const newDepContent = new TextDecoder("utf-8").decode(
Deno.readFileSync(upToDateDepsFile),
);
assertEquals(newDepContent === originalDepContent, true);
assertEquals(newDepContent, originalDepContent);
},
});

Deno.test({
name: "Should update when a custom dependency file path is given",
async fn(): Promise<void> {
try {
const p = await Deno.run({
cmd: [
"deno",
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"--allow-read",
Expand All @@ -183,14 +173,11 @@ Deno.test({
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output);
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(
stdout,
out,
colours.green("[INFO]") +
" Gathering information on your dependencies...\n" +
colours.green("[INFO]") +
Expand All @@ -214,9 +201,8 @@ Deno.test({
colours.green("[INFO]") +
` table-layout was updated from 2.0.0 to ${latestTableLayoutRelease}\n`,
);
assertEquals(stderr, "");
assertEquals(status.code, 0);
assertEquals(status.success, true);
assertEquals(err, "");
assertEquals(code, 0);
const originalDepContent = new TextDecoder("utf-8").decode(
Deno.readFileSync(outOfDateOriginalDepsFile),
);
Expand Down
27 changes: 14 additions & 13 deletions tests/integration/version_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import { version } from "../../src/commands/version.ts";
Deno.test({
name: "Should output the version correctly",
async fn(): Promise<void> {
const p = await Deno.run({
cmd: ["deno", "run", "--allow-net", "../../../mod.ts", "--version"],
const command = new Deno.Command(Deno.execPath(), {
args: [
"run",
"--allow-net",
"../../../mod.ts",
"--version",
],
cwd: upToDateDepsDir,
stdout: "piped",
stderr: "piped",
});
const status = await p.status();
const output = await p.output();
await p.close();
const stdout = new TextDecoder("utf-8").decode(output).replace(
const { code, stdout, stderr } = await command.output();
const out = new TextDecoder("utf-8").decode(stdout).replace(
/(\r\n|\n|\r)/gm,
"",
); // regex to strip line break
const error = await p.stderrOutput();
const stderr = new TextDecoder("utf-8").decode(error);
assertEquals(stdout, `Deno Module Manager v${version}`);
assertEquals(stderr, "");
assertEquals(status.code, 0);
assertEquals(status.success, true);
);
const err = new TextDecoder("utf-8").decode(stderr);
assertEquals(out, `Deno Module Manager v${version}`);
assertEquals(err, "");
assertEquals(code, 0);
},
});

0 comments on commit 9cd6b0b

Please sign in to comment.