mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 07:24:52 +09:00
Add config migrations (#693)
Co-authored-by: Danielv123 <danielv@danielv.no>
This commit is contained in:
1 parent
05ca4eb25e
commit
4248e57dcb
7 files changed
+43
-9
No files matched your search
@@ -7,6 +7,14 @@ const CA = lib.ConfigAccess;
|
||||
describe("lib/config/classes", function() {
|
||||
describe("Config", function() {
|
||||
class TestConfig extends lib.Config {
|
||||
static migrations(config) {
|
||||
if (config.hasOwnProperty("test.migration")) {
|
||||
config["alpha.foo"] = config["test.migration"];
|
||||
delete config["test.migration"];
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
static fieldDefinitions = {
|
||||
"alpha.foo": { type: "string", optional: true },
|
||||
"beta.bar": { type: "object", initialValue: {} },
|
||||
@@ -60,6 +68,13 @@ describe("lib/config/classes", function() {
|
||||
assert.equal(testInstance.fields["test.enum"], "b");
|
||||
assert.equal(testInstance.fields["test.priv"], undefined);
|
||||
});
|
||||
it("should apply migrations", function() {
|
||||
const config = new TestConfig("local", {
|
||||
"test.migration": "foo",
|
||||
});
|
||||
assert.equal(config.get("alpha.foo"), "foo");
|
||||
assert.equal(config.fields["test.migration"], undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe(".toJSON()", function() {
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ class MockController {
|
||||
this.app.locals.controller = this;
|
||||
this.app.locals.streams = new Map();
|
||||
this.mockConfigEntries = new Map([
|
||||
["controller.external_address", "test"],
|
||||
["controller.public_url", "test"],
|
||||
["controller.auth_secret", "TestSecretDoNotUse"],
|
||||
["controller.proxy_stream_timeout", 1],
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user