Skip to content

Commit

Permalink
fix(): Update tests to @godaddy/terminus@4.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Jun 17, 2019
1 parent d1a5d8d commit b68f57b
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 126 deletions.
2 changes: 1 addition & 1 deletion e2e/fasitfy.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Fastify', () => {
// Workaraound to wait until module is bootsrapped
setTimeout(async () => {
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.data).toEqual({ status: 'ok', info });
expect(response.data).toEqual({ status: 'ok', info, details: info });
done();
}, 40);
});
Expand Down
8 changes: 6 additions & 2 deletions e2e/health-checks/disk.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ describe('Disk Health', () => {
useFactory: getTerminusOptions,
});
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
const info = { disk: { status: 'up' } };
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { disk: { status: 'up' } },
info,
details: info,
});
});

Expand All @@ -58,10 +60,12 @@ describe('Disk Health', () => {
try {
await Axios.get(`http://0.0.0.0:${port}/health`);
} catch (error) {
const details = { disk: { status: 'down', message: expect.any(String) } };
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: { disk: { status: 'down', message: expect.any(String) } },
error: details,
details,
});
}
});
Expand Down
31 changes: 20 additions & 11 deletions e2e/health-checks/dns.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ describe('DNS Health', () => {
inject: [DNSHealthIndicator],
useFactory: getTerminusOptions,
});
const info = { dns: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { dns: { status: 'up' } },
info,
details: info,
});
});

Expand All @@ -50,13 +52,15 @@ describe('DNS Health', () => {
}),
});

const details = { dns: { status: 'down', message: expect.any(String) } };
try {
await Axios.get(`http://0.0.0.0:${port}/health`);
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: { dns: { status: 'down', message: expect.any(String) } },
error: details,
details,
});
}
});
Expand All @@ -77,13 +81,16 @@ describe('DNS Health', () => {
}),
});

const details = { dns: { status: 'down', message: expect.any(String) } };

try {
await Axios.get(`http://0.0.0.0:${port}/health`);
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: { dns: { status: 'down', message: expect.any(String) } },
error: details,
details,
});
}
});
Expand All @@ -107,20 +114,22 @@ describe('DNS Health', () => {
}),
});

const details = {
dns: {
status: 'down',
message: expect.any(String),
statusCode: 404,
statusText: 'Not Found',
},
};
try {
await Axios.get(`http://0.0.0.0:${port}/health`);
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: {
dns: {
status: 'down',
message: expect.any(String),
statusCode: 404,
statusText: 'Not Found',
},
},
error: details,
details,
});
}
});
Expand Down
17 changes: 12 additions & 5 deletions e2e/health-checks/memory.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ describe('Memory Health', () => {
inject: [MemoryHealthIndicator],
useFactory: getTerminusOptions,
});
const info = { memory_rss: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { memory_rss: { status: 'up' } },
info,
details: info,
});
});
});
Expand All @@ -64,11 +66,13 @@ describe('Memory Health', () => {
inject: [MemoryHealthIndicator],
useFactory: getTerminusOptions,
});
const info = { memory_heap: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { memory_heap: { status: 'up' } },
info,
details: info,
});
});

Expand All @@ -85,15 +89,18 @@ describe('Memory Health', () => {
}),
});

const details = {
memory_heap: { status: 'down', message: expect.any(String) },
};

try {
await Axios.get(`http://0.0.0.0:${port}/health`);
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: {
memory_heap: { status: 'down', message: expect.any(String) },
},
error: details,
details,
});
}
});
Expand Down
18 changes: 11 additions & 7 deletions e2e/health-checks/microservice.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ describe('Microservice Health', () => {
8890,
);

const info = { tcp: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { tcp: { status: 'up' } },
info,
details: info,
});
});

Expand Down Expand Up @@ -85,15 +87,17 @@ describe('Microservice Health', () => {
try {
await Axios.get(`http://0.0.0.0:${port}/health`, {});
} catch (error) {
const details = {
tcp: {
status: 'down',
message: expect.any(String),
},
};
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: {
tcp: {
status: 'down',
message: expect.any(String),
},
},
error: details,
details,
});
}
});
Expand Down
18 changes: 11 additions & 7 deletions e2e/health-checks/mongoose.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ describe('Mongoose Database Health', () => {
true,
);

const info = { mongo: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { mongo: { status: 'up' } },
info,
details: info,
});
});

Expand All @@ -56,18 +58,20 @@ describe('Mongoose Database Health', () => {
true,
);

const details = {
mongo: {
status: 'down',
message: expect.any(String),
},
};
try {
await Axios.get(`http://0.0.0.0:${port}/health`, {});
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: {
mongo: {
status: 'down',
message: expect.any(String),
},
},
error: details,
details,
});
}
});
Expand Down
18 changes: 11 additions & 7 deletions e2e/health-checks/typeorm.health.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ describe('TypeOrm Database Health', () => {
false,
);

const info = { typeorm: { status: 'up' } };
const response = await Axios.get(`http://0.0.0.0:${port}/health`);
expect(response.status).toBe(200);
expect(response.data).toEqual({
status: 'ok',
info: { typeorm: { status: 'up' } },
info,
details: info,
});
});

Expand All @@ -56,18 +58,20 @@ describe('TypeOrm Database Health', () => {
false,
);

const details = {
typeorm: {
status: 'down',
message: expect.any(String),
},
};
try {
await Axios.get(`http://0.0.0.0:${port}/health`, {});
} catch (error) {
expect(error.response.status).toBe(503);
expect(error.response.data).toEqual({
status: 'error',
error: {
typeorm: {
status: 'down',
message: expect.any(String),
},
},
error: details,
details,
});
}
});
Expand Down
Loading

0 comments on commit b68f57b

Please sign in to comment.