Testing

Learn to test the workflow that includes packaging.

Now that we have everything prepared, we can test our flow. If you didn’t deploy the project in the previous lesson, do it now:

import {
  APIGatewayProxyEvent,
  APIGatewayProxyHandler,
  APIGatewayProxyResult,
} from "aws-lambda";
import { validate as uuidValidate } from "uuid";

export const handler: APIGatewayProxyHandler = async (
  event: APIGatewayProxyEvent
): Promise<APIGatewayProxyResult> => {
  const batchId = event.body?.batchId;

  if (batchId && uuidValidate(batchId)) {
    return { validApiQualityCheck: true };
  } else {
    throw new Error("Quality check failed: invalid batch ID");
  }
};
Project

To deploy the project, we can use sls deploy.

Testing the packaging state

...