.end(end)
}
-function testVideoImage (url, videoName, imagePath, callback) {
+function testVideoImage (url, imageName, imagePath, callback) {
// Don't test images if the node env is not set
// Because we need a special ffmpeg version for this test
if (process.env.NODE_TEST_IMAGE) {
.end(function (err, res) {
if (err) return callback(err)
- fs.readFile(pathUtils.join(__dirname, '..', 'api', 'fixtures', videoName + '.jpg'), function (err, data) {
+ fs.readFile(pathUtils.join(__dirname, '..', 'api', 'fixtures', imageName + '.jpg'), function (err, data) {
if (err) return callback(err)
callback(null, data.equals(res.body))
}
const path = '/api/v1/videos/' + id
+ const body = {}
- const req = request(url)
- .put(path)
- .set('Accept', 'application/json')
- .set('Authorization', 'Bearer ' + accessToken)
+ if (attributes.name) body.name = attributes.name
+ if (attributes.category) body.category = attributes.category
+ if (attributes.licence) body.licence = attributes.licence
+ if (attributes.language) body.language = attributes.language
+ if (attributes.nsfw) body.nsfw = attributes.nsfw
+ if (attributes.description) body.description = attributes.description
+ if (attributes.tags) body.tags = attributes.tags
- if (attributes.name) req.field('name', attributes.name)
- if (attributes.category) req.field('category', attributes.category)
- if (attributes.licence) req.field('licence', attributes.licence)
- if (attributes.language) req.field('language', attributes.language)
- if (attributes.nsfw) req.field('nsfw', attributes.nsfw)
- if (attributes.description) req.field('description', attributes.description)
-
- if (attributes.tags) {
- for (let i = 0; i < attributes.tags.length; i++) {
- req.field('tags[' + i + ']', attributes.tags[i])
- }
- }
-
- req.expect(specialStatus).end(end)
+ request(url)
+ .put(path)
+ .send(body)
+ .set('Accept', 'application/json')
+ .set('Authorization', 'Bearer ' + accessToken)
+ .expect(specialStatus)
+ .end(end)
}
function rateVideo (url, accessToken, id, rating, specialStatus, end) {