Add automatic headless download and update

This commit is contained in:
Cooldude2606 committed 2026-02-05 00:45:53 +00:00
1 parent 1c7a32113a
commit 44abeace88
13 files changed
+177 -13

No files matched your search

@@ -0,0 +1,4 @@
; Test data for exportLocale
[test]
base-a=1
base-b=2
@@ -0,0 +1,3 @@
---------------------------------------------------------------------------------------------------
Version: 0.1.2
About: Dummy changelog.txt for FactorioServer tests
@@ -0,0 +1,4 @@
; Test data for exportLocale
[test]
core-a=1
core-b=2
@@ -0,0 +1,4 @@
; Test data for exportLocale
[test]
base-a=1
base-b=2
@@ -0,0 +1,3 @@
---------------------------------------------------------------------------------------------------
Version: 0.1
About: Dummy changelog.txt for FactorioServer tests
@@ -0,0 +1,4 @@
; Test data for exportLocale
[test]
core-a=1
core-b=2
+15 -7
View File
@@ -41,8 +41,8 @@ describe("host/server", function() {
it("should search given directory for latest Factorio install", async function() {
const installDir = path.join("test", "file", "factorio");
const [dir, version] = await hostServer._findVersion(installDir, "latest");
assert.equal(dir, path.join(installDir, "0.1.1", "data"));
assert.equal(version, "0.1.1");
assert.equal(dir, path.join(installDir, "0.1.2", "data"));
assert.equal(version, "0.1.2");
});
it("should search given directory for given Factorio install", async function() {
const installDir = path.join("test", "file", "factorio");
@@ -53,14 +53,14 @@ describe("host/server", function() {
it("should search given directory for partly given Factorio install", async function() {
const installDir = path.join("test", "file", "factorio");
const [dir, version] = await hostServer._findVersion(installDir, "0.1");
assert.equal(dir, path.join(installDir, "0.1.1", "data"));
assert.equal(version, "0.1.1");
assert.equal(dir, path.join(installDir, "0.1.2", "data"));
assert.equal(version, "0.1.2");
});
it("should reject if no factorio install with the given version was found", async function() {
let installDir = path.join("test", "file", "factorio");
await assert.rejects(
hostServer._findVersion(installDir, "0.1.2"),
new Error("Unable to find Factorio version 0.1.2")
hostServer._findVersion(installDir, "0.1.3"),
new Error("Unable to find Factorio version 0.1.3")
);
});
it("should reject if no factorio install was found", async function() {
@@ -72,6 +72,14 @@ describe("host/server", function() {
});
});
describe("_listFactorioVersions()", function() {
it("should list all versions in a directory", async function() {
const installDir = path.join("test", "file", "factorio");
const installedVersions = await hostServer._listFactorioVersions(installDir);
assert.deepEqual(installedVersions, new Set(["0.1.1", "0.1.2"]));
});
});
describe("randomDynamicPort()", function() {
it("should return a port number", function() {
let port = hostServer._randomDynamicPort();
@@ -144,7 +152,7 @@ describe("host/server", function() {
describe(".version", function() {
it("should return the version detected", function() {
assert.equal(server.version, "0.1.1");
assert.equal(server.version, "0.1.2");
});
});
+3 -3
View File
@@ -54,12 +54,12 @@ describe("FactorioVersions", function() {
{
stable: false,
version: "2.0.73",
headlessUrl: "www.factorio.com/get-download/2.0.73/headless/linux64",
headlessUrl: "https://www.factorio.com/get-download/2.0.73/headless/linux64",
},
{
stable: true,
version: "2.0.72",
headlessUrl: "www.factorio.com/get-download/2.0.72/headless/linux64",
headlessUrl: "https://www.factorio.com/get-download/2.0.72/headless/linux64",
},
]);
});
@@ -90,7 +90,7 @@ describe("FactorioVersions", function() {
{
stable: true,
version: "2.0.73",
headlessUrl: "www.factorio.com/get-download/2.0.73/headless/linux64",
headlessUrl: "https://www.factorio.com/get-download/2.0.73/headless/linux64",
},
]);
});