fix: Only show update message if current < latest (#1499)

This commit is contained in:
Marvin Hagemeister
2023-07-24 13:21:34 +02:00
committed by GitHub
parent 3c0657caa8
commit e18a608515
4 changed files with 64 additions and 9 deletions
+33
View File
@@ -188,3 +188,36 @@ Deno.test({
await Deno.remove(tmpDirName, { recursive: true });
},
});
Deno.test({
name: "only shows update message when current < latest",
async fn() {
const tmpDirName = await Deno.makeTempDir();
const checkFile: CheckFile = {
current_version: "9999.999.0",
latest_version: "1.2.0",
last_checked: new Date().toISOString(),
};
await Deno.writeTextFile(
join(tmpDirName, "latest.json"),
JSON.stringify(checkFile, null, 2),
);
const out = await new Deno.Command(Deno.execPath(), {
args: ["run", "-A", "./tests/fixture_update_check/mod.ts"],
env: {
HOME: tmpDirName,
LATEST_VERSION: versions[0],
CURRENT_VERSION: "99999.9999.00",
},
}).output();
const decoder = new TextDecoder();
const stdout = colors.stripColor(decoder.decode(out.stdout));
assertNotMatch(stdout, /Fresh .* is available/);
await Deno.remove(tmpDirName, { recursive: true });
},
});