mirror of
https://github.com/owncast/owncast.git
synced 2025-11-03 04:27:18 +08:00
Make the public dir live inside data to make volume mounting easier
This commit is contained in:
@ -4,7 +4,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const randomString = require('./lib/rand').randomString;
|
||||
|
||||
const publicPath = path.resolve(__dirname, '../../../public');
|
||||
const publicPath = path.resolve(__dirname, '../../../data/public');
|
||||
const filename = randomString() + '.txt';
|
||||
const fileContent = randomString();
|
||||
|
||||
@ -15,12 +15,12 @@ test('random public static file does not exist', async (done) => {
|
||||
});
|
||||
|
||||
test('public directory is writable', async (done) => {
|
||||
|
||||
try {
|
||||
writeFileToPublic();
|
||||
} catch (err) {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") { // path does not exist
|
||||
if (err.code === 'ENOENT') {
|
||||
// path does not exist
|
||||
fs.mkdirSync(publicPath);
|
||||
writeFileToPublic();
|
||||
} else {
|
||||
@ -33,25 +33,24 @@ test('public directory is writable', async (done) => {
|
||||
});
|
||||
|
||||
test('public static file is accessible', async (done) => {
|
||||
|
||||
request.get('/public/' + filename).expect(200).then((res) => {
|
||||
expect(res.text).toEqual(fileContent);
|
||||
done();
|
||||
});
|
||||
|
||||
request
|
||||
.get('/public/' + filename)
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
expect(res.text).toEqual(fileContent);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('public static file is persistent and not locked', async (done) => {
|
||||
|
||||
fs.unlink(path.join(publicPath, filename), (err) => {
|
||||
if (err) { throw err; }
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
function writeFileToPublic() {
|
||||
fs.writeFileSync(
|
||||
path.join(publicPath, filename),
|
||||
fileContent
|
||||
);
|
||||
}
|
||||
fs.writeFileSync(path.join(publicPath, filename), fileContent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user