Skip to content

Commit

Permalink
fix: broken links in readme.md (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlafConijn authored Jun 20, 2022
1 parent efa2f62 commit 0362729
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 35 deletions.
30 changes: 16 additions & 14 deletions cdk-v2-example/test/cdk-v2-example.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// import * as cdk from 'aws-cdk-lib';
// import { Template } from 'aws-cdk-lib/assertions';
// import * as CdkV2Example from '../lib/cdk-v2-example-stack';
import { main } from "../src/program";

// example test. To run these tests, uncomment this file along with the
// example resource in lib/cdk-v2-example-stack.ts
test('SQS Queue Created', () => {
// const app = new cdk.App();
// // WHEN
// const stack = new CdkV2Example.CdkV2ExampleStack(app, 'MyTestStack');
// // THEN
// const template = Template.fromStack(stack);
describe('when invoking program', () => {
it("returns proper greeting", async () => {
const result = await main({ name: "Fred" });
expect(result.greeting).toBe("Hello Fred");
})

// template.hasResourceProperties('AWS::SQS::Queue', {
// VisibilityTimeout: 300
// });
it("greets world when passed empty document", async () => {
const result = await main({} as any);
expect(result.greeting).toBe("Hello World");
})

it("no lucky number is the name", async () => {
const first = await main({} as any);
const second = await main({} as any);
expect(first.luckyNumber).not.toBe(second.luckyNumber);
})
});
13 changes: 3 additions & 10 deletions examples/pagination.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

## main
[Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IGFueSkgPT4gewogIHZhciBtYXJrZXI6IHN0cmluZyB8IHVuZGVmaW5lZDsKICBkbyB7CiAgICB2YXIgcmVzcG9uc2UgPSBhd2FpdCBhc2wuc2RrSUFNTGlzdFVzZXJzKHsKICAgICAgbmFtZTogIkxpc3QgVXNlcnMiLAogICAgICBwYXJhbWV0ZXJzOiB7CiAgICAgICAgUGF0aFByZWZpeDogIi9wYXRoIiwKICAgICAgICBNYXJrZXI6IG1hcmtlciwKICAgICAgfSwKICAgIH0pOwoKICAgIGZvciAoY29uc3QgdXNlciBvZiByZXNwb25zZS5Vc2VycyB8fCBbXSkgewogICAgICAvL3B1dCB5b3VyIGxvZ2ljIGhlcmUKICAgICAgYXdhaXQgZG9Tb21ldGhpbmcodXNlcik7CiAgICB9CiAgICBtYXJrZXIgPSByZXNwb25zZS5Jc1RydW5jYXRlZCA/IHJlc3BvbnNlLk1hcmtlciA6IHVuZGVmaW5lZDsKICB9IHdoaWxlIChtYXJrZXIpOwp9KTsK)
## list users
[Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IGFueSkgPT4gewogIHZhciBtYXJrZXI6IHN0cmluZyB8IHVuZGVmaW5lZDsKICBkbyB7CiAgICB2YXIgcmVzcG9uc2UgPSBhd2FpdCBhc2wuc2RrSUFNTGlzdFVzZXJzKHsKICAgICAgbmFtZTogIkxpc3QgVXNlcnMiLAogICAgICBwYXJhbWV0ZXJzOiB7CiAgICAgICAgUGF0aFByZWZpeDogIi9wYXRoIiwKICAgICAgICBNYXJrZXI6IG1hcmtlciwKICAgICAgfSwKICAgIH0pOwoKICAgIGZvciAoY29uc3QgdXNlciBvZiByZXNwb25zZS5Vc2VycyB8fCBbXSkgewogICAgICAvL3B1dCB5b3VyIGxvZ2ljIGhlcmUKICAgICAgYXdhaXQgZG9Tb21ldGhpbmcodXNlcik7CiAgICB9CiAgICBtYXJrZXIgPSByZXNwb25zZS5Jc1RydW5jYXRlZCA/IHJlc3BvbnNlLk1hcmtlciA6IHVuZGVmaW5lZDsKICB9IHdoaWxlIChtYXJrZXIpOwp9KTsKCmV4cG9ydCBjb25zdCBkb1NvbWV0aGluZyA9IGFzbC5kZXBsb3kuYXNTdGF0ZU1hY2hpbmUoYXN5bmMgKGlucHV0OiBVc2VyKSA9PiB7CiAgY29uc29sZS5sb2coaW5wdXQpOwp9KTsK)

``` typescript
export const main = asl.deploy.asStateMachine(async (input: any) => {
Expand All @@ -22,14 +22,7 @@ export const main = asl.deploy.asStateMachine(async (input: any) => {
} while (marker);
});

```


## do something
[Open in playground](https://asl-editor-spike-ts-stedi.vercel.app/?aW1wb3J0ICogYXMgYXNsIGZyb20gIkB0czJhc2wvYXNsLWxpYiIKCmV4cG9ydCBjb25zdCBtYWluID0gYXNsLmRlcGxveS5hc1N0YXRlTWFjaGluZShhc3luYyAoaW5wdXQ6IFVzZXIpID0+IHsKICBjb25zb2xlLmxvZyhpbnB1dCk7Cn0pOwo=)

``` typescript
export const main = asl.deploy.asStateMachine(async (input: User) => {
export const doSomething = asl.deploy.asStateMachine(async (input: User) => {
console.log(input);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as asl from "@ts2asl/asl-lib";
import { convertDeployExecute } from "../utility";
const { main, doSomething } = require("../resources/pagination");
const { listUsers, doSomething } = require("../resources/pagination");
jest.setTimeout(99999999);

describe("when converting pagination", () => {
it("will execute main as if it were node", async () => {
const resultFromSfn = await convertDeployExecute("pagination", "main");
const resultFromNode = await main({}, asl.testing.createTestContext({}));
it("will execute listUsers as if it were node", async () => {
const resultFromSfn = await convertDeployExecute("pagination", "listUsers");
const resultFromNode = await listUsers({}, asl.testing.createTestContext({}));
expect(resultFromSfn).toEqual(resultFromNode);
});
it("will execute doSomething as if it were node", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as asl from "@ts2asl/asl-lib"

export const main = asl.deploy.asStateMachine(async (input: any) => {
export const listUsers = asl.deploy.asStateMachine(async (input: any) => {
var marker: string | undefined;
do{
var response = await asl.sdkIAMListUsers({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as asl from "@ts2asl/asl-lib"

export const main = asl.deploy.asStateMachine(async (input: any) =>{
export const listUsers = asl.deploy.asStateMachine(async (input: any) =>{
var marker: string | undefined = asl.pass({
name: "Assign marker",
comment: "marker: string | undefined"
Expand Down
2 changes: 1 addition & 1 deletion packages/convert/src/__test__/resources/pagination.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import * as asl from "@ts2asl/asl-lib"

export const main = asl.deploy.asStateMachine(async (input: any) => {
export const listUsers = asl.deploy.asStateMachine(async (input: any) => {
var marker: string | undefined;
do{
var response = await asl.sdkIAMListUsers({
Expand Down
4 changes: 2 additions & 2 deletions packages/convert/src/__test__/tests/pagination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe("when converting pagination", () => {
beforeAll(() => {
converted = runConvertForTest("pagination");
});
it("then main can be converted to asl", async () => {
expect(converted.main.asl).toMatchInlineSnapshot(`
it("then listUsers can be converted to asl", async () => {
expect(converted.listUsers.asl).toMatchInlineSnapshot(`
Object {
"StartAt": "Initialize",
"States": Object {
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ new ts2asl.TypescriptStateMachine(this, "TypescriptStateMachine", {
```

## Useful patterns & examples
- [example project](./cdk-example/) containing a [simple program](./cdk-example/src/program.ts), [CDK for deployment](./cdk-example/lib/cdk-example-stack.ts) and [Jest for testing](./cdk-example/test/program.test.ts)
- Waiting for completion of SDK state: [organizations.createAccount](./examples/switch.md#create-aws-account).
- [example project](./cdk-v2-example/) containing a [simple program](./cdk-v2-example/src/program.ts), [CDK for deployment](./cdk-v2-example/lib/cdk-v2-example-stack.ts) and [Jest for testing](./cdk-v2-example/test/cdk-v2-example.test.ts)
- waiting for completion of SDK state: [organizations.createAccount](./examples/switch.md#create-aws-account).
- pagination over list: [iam.listUsers](./examples/pagination.md#list-users).
<!--
- Using sdk integrations to page over data in DynamoDB
- Using a Lambda to page over data (in memory)
Expand Down
2 changes: 2 additions & 0 deletions tools/convert-test-generator/generate-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const exampleMetadata: Record<string, ExampleMetadata> = {
"input-validation/notEquals": { description: ""},
"kyc/main": { description: ""},
"map/main": { description: ""},
"pagination/doSomething": { skip: true},
"pagination/listUsers": { dependentTestCases: ["doSomething"] },
"nested-stepfunctions/childStateMachine": { skip: true},
"nested-stepfunctions/callStateMachineNoAwait": {dependentTestCases: ["childStateMachine"]},
"nested-stepfunctions/callStateMachineWithAwait": {dependentTestCases: ["childStateMachine"]},
Expand Down

0 comments on commit 0362729

Please sign in to comment.