amplify-education / serverless-vpc-discovery

Serverless plugin for discovering VPC / Subnet / Security Group configuration by name.
MIT License
38 stars 15 forks source link

Fix unit test expectations not being run #40

Closed RLRabinowitz closed 3 years ago

RLRabinowitz commented 3 years ago

Most of the unit tests are not run correctly, since they return a Promise and never wait for that Promise to resolve, so most of the expectations are not run at all. If you add expect(true).to.equal(false) to the then of tests using getFuncVPC, the test will wrongfully pass.

This is fixed by adding await where relevant. However, this has revealed that some tests' inputs and expected outputs are wrong, and some tests are not mocked correctly.

  1. AWS needs to be mocked before initResources is called.
  2. In describe("Given invalid input..., the input data does not match AWS mock
  3. In describe("Given valid inputs..., the test wrongfully assumes that the plugin filters out subnetNames by the input (or this is simply a wrong input)
rddimon commented 3 years ago

Hi @RLRabinowitz

Thank you very much for the fix

RLRabinowitz commented 3 years ago

Thank you very much for the fix

Sure, no problem! @rddimon could you merge this for me?

rddimon commented 3 years ago

Sure,

We are also working on a new feature for the plugin and planning to release it by the end of next week So be ready for that