feat: commit inicial da aplicacao com pipeline

This commit is contained in:
2026-06-29 23:04:57 -03:00
parent 87fd60e82f
commit e9bb8d83b0
7 changed files with 310 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
// ============================================================
// Testes automatizados da aplicação
// O Jenkins executa estes testes a cada push.
// Se QUALQUER teste falhar, o pipeline para e NÃO faz deploy.
// Isso é o "firewall de qualidade" do CI/CD.
// ============================================================
const request = require('supertest');
const app = require('../src/index');
describe('Rota Principal GET /', () => {
test('deve retornar status 200', async () => {
const res = await request(app).get('/');
expect(res.statusCode).toBe(200);
});
test('deve retornar o nome da aplicação', async () => {
const res = await request(app).get('/');
expect(res.body).toHaveProperty('app', 'CI/CD Demo');
});
test('deve retornar status "rodando"', async () => {
const res = await request(app).get('/');
expect(res.body).toHaveProperty('status', 'rodando');
});
test('deve conter um timestamp', async () => {
const res = await request(app).get('/');
expect(res.body).toHaveProperty('timestamp');
});
});
describe('Health Check GET /health', () => {
test('deve retornar status 200', async () => {
const res = await request(app).get('/health');
expect(res.statusCode).toBe(200);
});
test('deve retornar status "healthy"', async () => {
const res = await request(app).get('/health');
expect(res.body).toHaveProperty('status', 'healthy');
});
});
describe('Informações do Sistema GET /info', () => {
test('deve retornar versão do Node.js', async () => {
const res = await request(app).get('/info');
expect(res.statusCode).toBe(200);
expect(res.body).toHaveProperty('node_version');
});
test('deve retornar uptime em segundos', async () => {
const res = await request(app).get('/info');
expect(res.body).toHaveProperty('uptime_seconds');
expect(typeof res.body.uptime_seconds).toBe('number');
});
});