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
language: c | |
before_install: | |
- sudo apt-get update -qq > /dev/null | |
- sudo apt-get install mono-devel mono-gmcs nunit-console | |
- mozroots --import --sync | |
- mv -f src/.nuget/NuGet.mono.targets src/.nuget/NuGet.targets | |
- export EnableNuGetPackageRestore=true | |
script: |
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
var dns = require('dns'); | |
function reverseLookup(ip) { | |
dns.reverse(ip,function(err,domains){ | |
if(err!=null) callback(err); | |
domains.forEach(function(domain){ | |
dns.lookup(domain,function(err, address, family){ | |
console.log(domain,'[',address,']'); | |
console.log('reverse:',ip==address); |
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
const logger = require('knoblr') | |
const mongoose = require('mongoose') | |
const Koa = require('koa') | |
const jwt = require('koa-jwt') | |
const parser = require('koa-body')() | |
const cors = require('../shared/configs/cors') | |
const ServerException = require('../shared/errors/ServerException') | |
/** | |
* Realiza a conexão no banco de dados |
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
const FileNotFoundException = require('./shared/errors/FileNotFoundException') // Classe de erro de arquivo não encontrado | |
if (!require('fs').existsSync('.env')) { // Verifica se o arquivo de variáveis de ambiente existe | |
require('knoblr').error('O arquivo .env não existe, por favor crie um') // Loga o erro no console | |
throw new FileNotFoundException('.env') // Envia o erro para o usuário | |
} else { | |
require('dotenv').config({ // Carrega todas as variáveis de ambiente | |
silent: true | |
}) |
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
const route = require('koa-route') | |
const logger = require('knoblr') | |
const mongoose = require('mongoose') | |
/** | |
* Rota de obtenção de status da API | |
* | |
* @param {Object} ctx Contexto do Koa (Preenchido automaticamente) | |
* @param {Object} next Próximo middleware do Koa (Preenchido automaticamente) | |
* @param {Mongoose} driver Model do Mongoose |
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
describe('Should return 200 when both the api and the database are ok', (assert) => { // Descrição do código | |
assert.plan(1) // Planeja que vamos ter apenas 1 verificação neste teste | |
let dbMock = { // Cria um modelo do objeto do banco de dados apenas com as propriedades que a rota chama | |
connection: { // Na nossa rota verificamos esta propriedade do banco de dados apenas | |
readyState: 1 // Vamos forçar uma conexão estabelecida | |
} | |
} | |
func(assert.context.routeContext, null, dbMock) // Chamamos nossa função | |
assert.deepEqual(assert.context.routeContext.status, 200) // Fazemos a verificação | |
}) |
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
describe('Exemplo de stub com Sinon', (assert) => { | |
var message = 'an example message'; | |
var stub = sinon.stub().throws(); | |
var spy1 = sinon.spy(); | |
var spy2 = sinon.spy(); | |
PubSub.subscribe(message, stub); | |
PubSub.subscribe(message, spy1); | |
PubSub.subscribe(message, spy2); |
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
describe('Exemplo de Mock', (assert) => { | |
var myAPI = { method: function () {} }; | |
var spy = sinon.spy(); | |
var mock = sinon.mock(myAPI); | |
mock.expects("método").once().throws(); // Substituímos o "método" por outra função previsível | |
PubSub.subscribe("message", myAPI.method); | |
PubSub.subscribe("message", spy); | |
PubSub.publishSync("message", undefined); |
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
var TaskManager = function(){ | |
var taskList = []; | |
return { | |
addTask: function(task){ | |
taskList.push(task); | |
}, | |
tasksCount: function(){ | |
return taskList.length; | |
} |
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
var xhr, requests; | |
before(function { | |
xhr = sinon.useFakeXMLHttpRequest(); | |
requests = []; | |
xhr.onCreate = function (req) { requests.push(req); }; | |
}); | |
after(function () { | |
xhr.restore(); // Limpa o objeto quando estamos trabalhando com globais |
OlderNewer