feat: test integration connection (#669)

* feat: add test integration for pi-hole

* refactor: test integration for pi-hole

* fix: multiple secrets of same type could be used for integration creation

* fix: remove integration test connection test and add mock for test-connection function

* fix: add missing onUpdateFn to mysql integration secrets

* fix: format issues

* feat: add home assistant test connection

* fix: deepsource issues

* test: add system integration tests for test connection

* fix: add before all for pulling home assistant image

* test: add unit tests for handleTestConnectionResponseAsync

* test: add unit test for testConnectionAsync

* test: add mroe tests to integration-test-connection

* fix: deepsource issues

* fix: deepsource issue

* chore: address pull request feedback
This commit is contained in:
Meier Lukas
2024-06-22 21:02:04 +02:00
committed by GitHub
parent 92afd82d22
commit f92aeba403
30 changed files with 1138 additions and 550 deletions

View File

@@ -25,6 +25,36 @@ describe("Pi-hole integration", () => {
// Cleanup
await piholeContainer.stop();
}, 20_000); // Timeout of 20 seconds
test("testConnectionAsync should not throw", async () => {
// Arrange
const piholeContainer = await createPiHoleContainer(DEFAULT_PASSWORD).start();
const piHoleIntegration = createPiHoleIntegration(piholeContainer, DEFAULT_API_KEY);
// Act
const actAsync = async () => await piHoleIntegration.testConnectionAsync();
// Assert
await expect(actAsync()).resolves.not.toThrow();
// Cleanup
await piholeContainer.stop();
}, 20_000); // Timeout of 20 seconds
test("testConnectionAsync should throw with wrong credentials", async () => {
// Arrange
const piholeContainer = await createPiHoleContainer(DEFAULT_PASSWORD).start();
const piHoleIntegration = createPiHoleIntegration(piholeContainer, "wrong-api-key");
// Act
const actAsync = async () => await piHoleIntegration.testConnectionAsync();
// Assert
await expect(actAsync()).rejects.toThrow();
// Cleanup
await piholeContainer.stop();
}, 20_000); // Timeout of 20 seconds
});
const createPiHoleContainer = (password: string) => {