Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/microcks-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ describe("MicrocksContainer", () => {
async function testInvocationsCheckingFunctionality(container: StartedMicrocksContainer,
serviceName: string, serviceVersion: string, expectedCount: number) {
expect(await container.verify(serviceName, serviceVersion)).toBe(true);
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion)).toBe(expectedCount)
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion)).toBe(expectedCount);
expect(await container.verify(serviceName, serviceVersion, new Date())).toBe(true);
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion, new Date())).toBe(expectedCount);
}

// start and contract test {
Expand Down
22 changes: 11 additions & 11 deletions src/microcks-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
});

if (response.status != 201) {
throw new Error("Secret has not been correctly created: " + await response.json());
throw new Error("Secret has not been correctly created: " + await response.text());
}
}

Expand Down Expand Up @@ -536,7 +536,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
}
return testResult;
}
throw new Error("Couldn't launch on new test on Microcks. Please check Microcks container logs.");
throw new Error("Couldn't launch a new test on Microcks. Please check Microcks container logs.");
}

/**
Expand All @@ -561,7 +561,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
const responseJson = await response.json();
return responseJson as RequestResponsePair[];
}
throw new Error("Couldn't retrieve messages on test on Microcks. Please check Microcks container logs");
throw new Error("Couldn't retrieve messages for test on Microcks. Please check Microcks container logs");
}

/**
Expand All @@ -586,7 +586,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
const responseJson = await response.json();
return responseJson as UnidirectionalEvent[];
}
throw new Error("Couldn't retrieve event messages on test on Microcks. Please check Microcks container logs");
throw new Error("Couldn't retrieve event messages for test on Microcks. Please check Microcks container logs");
}

/**
Expand Down Expand Up @@ -623,15 +623,15 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
private async importArtifact(artifactPath: string, mainArtifact: boolean): Promise<void> {
const isFile = await this.isFile(artifactPath);
if (!isFile) {
throw new Error(`Artifact ${artifactPath} does not exist or can't be read`);
throw new Error(`Artifact ${artifactPath} does not exist or can't be read`);
}

// Actually upload the file to upload endpoint.
const uploadURI = this.getHttpEndpoint() + "/api/artifact/upload" + (mainArtifact ? "" : "?mainArtifact=false");
const response = await this.uploadFileToMicrocks(uploadURI, artifactPath, "application/octet-stream");

if (response.status != 201) {
throw new Error("Artifact has not been correctly been imported: " + await response.json());
throw new Error("Artifact has not been correctly imported: " + await response.text());
}
}

Expand All @@ -657,21 +657,21 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
})

if (response.status != 201) {
throw new Error("Artifact has not been correctly downloaded: " + await response.json());
throw new Error("Artifact has not been correctly downloaded: " + await response.text());
}
}

private async importSnapshotInternal(snapshotPath: string): Promise<void> {
const isFile = await this.isFile(snapshotPath);
if (!isFile) {
throw new Error(`Snapshot ${snapshotPath} does not exist or can't be read`);
throw new Error(`Snapshot ${snapshotPath} does not exist or can't be read`);
}

// Actually upload the file to upload endpoint.
const response = await this.uploadFileToMicrocks(this.getHttpEndpoint() + "/api/import", snapshotPath, "application/json");

if (response.status != 201) {
throw new Error("Snapshot has not been correctly been imported: " + await response.json());
throw new Error("Snapshot has not been correctly imported: " + await response.text());
}
}

Expand Down Expand Up @@ -762,8 +762,8 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
}

private formatDate(invocationDate: Date): string {
const month = invocationDate.getMonth() < 10 ? `0${invocationDate.getMonth()}` : `${invocationDate.getMonth()}`
const day = invocationDate.getDate() < 10 ? `0${invocationDate.getDate()}` : `${invocationDate.getDate()}`;
const month = (invocationDate.getMonth() + 1).toString().padStart(2, "0");
const day = invocationDate.getDate().toString().padStart(2, "0");
return `${invocationDate.getFullYear()}${month}${day}`;
}
}