Skip to content

Commit

Permalink
added configuration_id field in message_view
Browse files Browse the repository at this point in the history
  • Loading branch information
acuiuli committed Feb 7, 2024
1 parent cd3a9f7 commit dc860ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/models/__tests__/message_view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,31 @@ describe("message_view", () => {
expect(E.isLeft(result)).toBeTruthy();
});

it("GIVEN a valid message_view object with thirdParty WHEN the object contain an invalid configuration_id THEN the decode fails", async () => {
const messageViewWithThirdParty = {
...aMessageView,
components: {
...aMessageView.components,
thirdParty: {
has: true,
id: "AN_ID",
configuration_id: "anInvalidUlid"
}
}
};
const result = MessageView.decode(messageViewWithThirdParty);
expect(E.isLeft(result)).toBeTruthy();
});

it("GIVEN a valid message_view object with thirdParty WHEN the object contains a valid id THEN the decode succeed", async () => {
const messageViewWithThirdParty = {
...aMessageView,
components: {
...aMessageView.components,
thirdParty: {
has: true,
id: "AN_ID"
id: "AN_ID",
configuration_id: "01ARZ3NDEKTSV4RRFFQ69G5FAV"
}
}
};
Expand Down Expand Up @@ -229,6 +246,7 @@ describe("message_view", () => {
);
}
});


it("GIVEN a valid message_view without third party object WHEN the object is decode THEN the decode succeed", async () => {
const { thirdParty, ...componentsWithoutThirdParty } = aComponents;
Expand Down
3 changes: 2 additions & 1 deletion src/models/message_view.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "io-ts";
import { NonEmptyString } from "@pagopa/ts-commons/lib/strings";
import { NonEmptyString, Ulid } from "@pagopa/ts-commons/lib/strings";
import { Container } from "@azure/cosmos";
import { NonNegativeInteger } from "@pagopa/ts-commons/lib/numbers";
import { enumType, withDefault } from "@pagopa/ts-commons/lib/types";
Expand Down Expand Up @@ -55,6 +55,7 @@ export const ThirdPartyComponent = t.union([
id: NonEmptyString
}),
t.partial({
configuration_id: Ulid,
has_precondition: enumType<HasPreconditionEnum>(
HasPreconditionEnum,
"has_precondition"
Expand Down

0 comments on commit dc860ba

Please sign in to comment.