Skip to content

Commit

Permalink
agrego nuevos tests de files
Browse files Browse the repository at this point in the history
  • Loading branch information
hiuxmaycry committed Apr 23, 2018
1 parent e536721 commit 76cc0b7
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 110 deletions.
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
- db:database
db:
container_name: postgres
image: postgres
image: postgres8.4.1
restart: always
# ports:
# - "3052:5432"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start-prod-heroku": "npm install sequelize sequelize-cli pg && npm install && sequelize db:migrate --env=production && PRODUCTION_HEROKU=1 node ./bin/www",
"debug": "PORT=3001 node --inspect=0.0.0.0:9229 ./bin/www",
"tests": "sequelize db:migrate:undo:all --env=test && sequelize db:migrate --env=test && NODE_ENV=test node_modules/.bin/mocha tests/* --recursive --exit ",
"tests": "sequelize db:migrate:undo:all --env=test && sequelize db:migrate --env=test && sequelize db:seed:all --seeders-path=/usr/src/tests/seeders/ --env=test && NODE_ENV=test node_modules/.bin/mocha tests/* --recursive --exit ",
"tests_seeds": "sequelize db:migrate:undo:all --env=test && sequelize db:migrate --env=test && sequelize db:seed:all --seeders-path=/usr/src/tests/seeders/ --env=test && NODE_ENV=test node_modules/.bin/mocha tests/* --recursive --exit ",
"nyc_tests": "sequelize db:migrate:undo:all --env=test && sequelize db:migrate --env=test && NODE_ENV=test node_modules/.bin/nyc node_modules/.bin/mocha tests/* --recursive --exit ",
"reset_dev": "sequelize db:migrate:undo:all && sequelize db:migrate && sequelize db:seed:all "
},
Expand Down
64 changes: 0 additions & 64 deletions tests/routes/v0/bootstrapping.js

This file was deleted.

72 changes: 72 additions & 0 deletions tests/services/fileService_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict'
require('dotenv').config({path: '.env.test'})
let assert = require('chai').assert
let describe = require('mocha').describe
let it = require('mocha').it
let models = require('../../models/sequelize')
const fileService = require('../../services/fileService')(models)

let idFileCreado
let revViejo
let originalname = 'originalname'
let filename = 'filename'

describe('Verificaciones sobre FileService', function () {
it('Obtener un file que no existe', function (done) {
fileService.get('-1').catch(function (e) {
assert(e.status === 404, 'El file existe')
done()
})
})
it('Agregar un file', function (done) {
let path = 'un path'
let params = {
id: null,
_rev: null,
created_at: null,
updated_at: null,
size: null,
filename: null,
resource: null
}
let file = {
filename: filename,
originalname: originalname,
path: path,
size: 100
}
fileService.create(file, params).then((file) => {
assert(file.id !== null, 'El file no existe')
idFileCreado = file.id
assert(file.resource === path, 'El file no tiene bien el resource')
assert(file.filename === originalname, 'El file no tiene bien el filename')
assert(file._rev != null, 'El _rev no se completo')
revViejo = file._rev
done()
})
})
it('Obtener un file', function (done) {
fileService.get(idFileCreado.toString()).then((path_filename) => {
assert(path_filename == filename, 'El file no tiene bien el filename')
done()
})
})
it('Edito un file', function (done) {
let filename2 = 'filename2'
let params = {
id: idFileCreado,
_rev: revViejo,
created_at: null,
updated_at: null,
size: 1200,
filename: filename2,
resource: filename2
}
fileService.update(idFileCreado, params).then((file) => {
assert(file.id !== null, 'El file no existe')
assert(file.filename === filename2, 'El file no tiene bien el filename')
assert(file._rev != revViejo, 'El _rev no se modifico')
done()
})
})
})
44 changes: 0 additions & 44 deletions tests/services/filesService_test.js

This file was deleted.

72 changes: 72 additions & 0 deletions tests/services/serverService_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*'use strict'
require('dotenv').config({path: '.env.test'})
let assert = require('chai').assert
let describe = require('mocha').describe
let it = require('mocha').it
let models = require('../../models/sequelize')
const fileService = require('../../services/fileService')(models)
let idFileCreado
let revViejo
let originalname = 'originalname'
let filename = 'filename'
describe('Verificaciones sobre FileService', function () {
it('Obtener un file que no existe', function (done) {
fileService.get('-1').catch(function (e) {
assert(e.status === 404, 'El file existe')
done()
})
})
it('Agregar un file', function (done) {
let path = 'un path'
let params = {
id: null,
_rev: null,
created_at: null,
updated_at: null,
size: null,
filename: null,
resource: null
}
let file = {
filename: filename,
originalname: originalname,
path: path,
size: 100
}
fileService.create(file, params).then((file) => {
assert(file.id !== null, 'El file no existe')
idFileCreado = file.id
assert(file.resource === path, 'El file no tiene bien el resource')
assert(file.filename === originalname, 'El file no tiene bien el filename')
assert(file._rev != null, 'El _rev no se completo')
revViejo = file._rev
done()
})
})
it('Obtener un file', function (done) {
fileService.get(idFileCreado.toString()).then((path_filename) => {
assert(path_filename == filename, 'El file no tiene bien el filename')
done()
})
})
it('Edito un file', function (done) {
let filename2 = 'filename2'
let params = {
id: idFileCreado,
_rev: revViejo,
created_at: null,
updated_at: null,
size: 1200,
filename: filename2,
resource: filename2
}
fileService.update(idFileCreado, params).then((file) => {
assert(file.id !== null, 'El file no existe')
assert(file.filename === filename2, 'El file no tiene bien el filename')
assert(file._rev != revViejo, 'El _rev no se modifico')
done()
})
})
})*/

0 comments on commit 76cc0b7

Please sign in to comment.