Skip to content

Commit 2e8b58b

Browse files
fix date format (#204)
Signed-off-by: DivyanshuVorrtex <divyanshuchandra9027@gmail.com>
1 parent 83965f6 commit 2e8b58b

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

src/microcks-container.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ describe("MicrocksContainer", () => {
135135
async function testInvocationsCheckingFunctionality(container: StartedMicrocksContainer,
136136
serviceName: string, serviceVersion: string, expectedCount: number) {
137137
expect(await container.verify(serviceName, serviceVersion)).toBe(true);
138-
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion)).toBe(expectedCount)
138+
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion)).toBe(expectedCount);
139+
expect(await container.verify(serviceName, serviceVersion, new Date())).toBe(true);
140+
expect(await container.getServiceInvocationsCount(serviceName, serviceVersion, new Date())).toBe(expectedCount);
139141
}
140142

141143
// start and contract test {

src/microcks-container.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
505505
});
506506

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

@@ -536,7 +536,7 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
536536
}
537537
return testResult;
538538
}
539-
throw new Error("Couldn't launch on new test on Microcks. Please check Microcks container logs.");
539+
throw new Error("Couldn't launch a new test on Microcks. Please check Microcks container logs.");
540540
}
541541

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

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

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

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

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

@@ -657,21 +657,21 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
657657
})
658658

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

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

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

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

@@ -762,8 +762,8 @@ export class StartedMicrocksContainer extends AbstractStartedContainer {
762762
}
763763

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

0 commit comments

Comments
 (0)