Skip to content

Commit b46544e

Browse files
authored
Merge pull request #59 from antmendoza/support-creation-metadata
Support creation metadata
2 parents 5ee1cfd + c098366 commit b46544e

File tree

7 files changed

+207
-54
lines changed

7 files changed

+207
-54
lines changed

package-lock.json

Lines changed: 85 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/metadata-builder.spec.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2021-Present The Serverless Workflow Specification Authors
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
import {MetadataBuilder} from '../src/model/metadata.builder';
18+
19+
20+
describe("MetadataBuilder", () => {
21+
22+
it("should create an empty object ", () => {
23+
24+
expect(new MetadataBuilder().build()).toEqual({});
25+
26+
});
27+
28+
it("should create an object with key/value strings ", () => {
29+
30+
expect(new MetadataBuilder()
31+
.withKeyValue("k1", "v1")
32+
.build()).toEqual(
33+
{
34+
"k1": "v1",
35+
});
36+
37+
38+
expect(new MetadataBuilder()
39+
.withKeyValue("k2", "v2")
40+
.withKeyValue("k3", "v3")
41+
.build()).toEqual(
42+
{
43+
"k2": "v2",
44+
"k3": "v3",
45+
});
46+
47+
48+
});
49+
50+
51+
it("should allow to overwrite pairs of key/value ", () => {
52+
53+
expect(new MetadataBuilder()
54+
.withKeyValue("k1", "v1")
55+
.withKeyValue("k1", "v2")
56+
.build()).toEqual(
57+
{
58+
"k1": "v2",
59+
});
60+
61+
62+
});
63+
64+
65+
});
66+
67+
68+

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export {EventRefBuilder} from "./model/event-ref.builder";
2626
export {FunctionBuilder} from "./model/function.builder";
2727
export {FunctionRefImplBuilder} from "./model/function-ref-impl.builder";
2828
export {InjectStateBuilder} from "./model/inject-state.builder";
29+
export {MetadataBuilder} from "./model/metadata.builder";
2930
export {OperationStateBuilder} from "./model/operation-state.builder";
3031
export {ProduceEventDefBuilder} from "./model/produce-event-def.builder";
3132
export {RepeatBuilder} from "./model/repeat.builder";

0 commit comments

Comments
 (0)