-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 make sqlite filename absolute (#7585)
no issue - add tests for makePathsAbsolute - add support for windows paths When Ghost-CLI inits the database of the current GhostVersion (in /current), then it uses knex-migrator to do that. Knex migrator is reading the .knex-migrator file of the current Ghost version. This returns a relative path to the database location. The problem: knex-migrator will init the database in the root folder of Ghost-CLI /content/data instead of /current/content . And when you start Ghost (ghost start), it always complains that that database is not initialised, because it expects the database in /current/content... * 🎨 move config_spec to config/index_spec - add one more test case
- Loading branch information
Showing
4 changed files
with
117 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
var configUtils = require('../../../server/config/utils'), | ||
should = require('should'); | ||
|
||
should.equal(true, true); | ||
|
||
describe('UNIT: Config utils', function () { | ||
describe('makePathsAbsolute', function () { | ||
it('ensure we change paths only', function () { | ||
var changedKey = [], | ||
obj = { | ||
database: { | ||
client: 'mysql', | ||
connection: { | ||
filename: 'content/data/ghost.db' | ||
} | ||
} | ||
}; | ||
|
||
this.set = function (key, value) { | ||
changedKey.push([key, value]); | ||
}; | ||
|
||
configUtils.makePathsAbsolute.bind(this)(obj.database, 'database'); | ||
|
||
changedKey.length.should.eql(1); | ||
changedKey[0][0].should.eql('database:connection:filename'); | ||
changedKey[0][1].should.not.eql('content/data/ghost.db'); | ||
}); | ||
|
||
it('ensure it skips non strings', function () { | ||
var changedKey = [], | ||
obj = { | ||
database: { | ||
test: 10 | ||
} | ||
}; | ||
|
||
this.set = function (key, value) { | ||
changedKey.push([key, value]); | ||
}; | ||
|
||
configUtils.makePathsAbsolute.bind(this)(obj.database, 'database'); | ||
changedKey.length.should.eql(0); | ||
}); | ||
|
||
it('ensure we don\' change absolute paths', function () { | ||
var changedKey = [], | ||
obj = { | ||
database: { | ||
client: 'mysql', | ||
connection: { | ||
filename: '/content/data/ghost.db' | ||
} | ||
} | ||
}; | ||
|
||
this.set = function (key, value) { | ||
changedKey.push([key, value]); | ||
}; | ||
|
||
configUtils.makePathsAbsolute.bind(this)(obj.database, 'database'); | ||
changedKey.length.should.eql(0); | ||
}); | ||
|
||
it('match paths on windows', function () { | ||
var changedKey = [], | ||
obj = { | ||
database: { | ||
filename: 'content\\data\\ghost.db' | ||
} | ||
}; | ||
|
||
this.set = function (key, value) { | ||
changedKey.push([key, value]); | ||
}; | ||
|
||
configUtils.makePathsAbsolute.bind(this)(obj.database, 'database'); | ||
changedKey.length.should.eql(1); | ||
changedKey[0][0].should.eql('database:filename'); | ||
changedKey[0][1].should.not.eql('content\\data\\ghost.db'); | ||
}); | ||
}); | ||
}); |