You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Intrinsic function short form usage in integration test fixtures causes fixture loading to fail #8627
When writing an integration test for the framework, using any intrinsic function short syntax - i.e. !GetAtt instead of Fn::GetAtt - causes fixtures.setup to return null without triggering an error. This is quite confusing as short syntax is perfectly fine for deploying the same service in the context of an actual project.
In the exemple of test/fixtures/httpApiExport/serverless.yml, using Ref: HttpApi works perfectly fine
When writing an integration test for the framework, using any intrinsic function short syntax - i.e. !GetAtt instead of Fn::GetAtt - causes fixtures.setup to return null without triggering an error.
This should be picked by runServerless with config validation, and run should fail with meaningful error. Wasn't that the case?
This shorthand syntax is not part of the config extension, but is part of the serverless.yml file within the httpApiExport test fixture. If you go in this fixture directory - test/fixtures/httpApiExport - and run the sls deploy command with the short syntax in the serverless.yml, everything is fine. If you run a test with this service file, it silently crashes since fixtures.setup returns null
While just for fixture setup purpose I would argue, that we can simply not use shorthand syntax. Still I think it's valuable to have support for that, for the sake of testing that short syntax works as expected.
Could you release a new version of this package and I'll produce a PR on serverless/serverless to update the @serverlerss/test version ?
Sure, it's released now. Still there's no need to bump version in serverless, as CI automatically is run against latest version of dependencies and we always bump dependencies prior releasing new version (so it's guaranteed to happen then)
Activity
medikoo commentedon Dec 15, 2020
This should be picked by
runServerlesswith config validation, and run should fail with meaningful error. Wasn't that the case?medikoo commentedon Dec 15, 2020
Additionally we accept JSON as config extension, and short syntax is specific to YAML, so I don't think this really apply here.
fredericbarthelet commentedon Dec 15, 2020
@medikoo, sorry, I was not precise enough.
The failing line in my exemple command
AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx npx mocha test/integration/httpApi.test.jsisserverless/test/integration/httpApi.test.js
Line 230 in c864fbd
This shorthand syntax is not part of the config extension, but is part of the
serverless.ymlfile within thehttpApiExporttest fixture. If you go in this fixture directory -test/fixtures/httpApiExport- and run thesls deploycommand with the short syntax in the serverless.yml, everything is fine. If you run a test with this service file, it silently crashes sincefixtures.setupreturns nullDo you see what I mean ?
medikoo commentedon Dec 16, 2020
@fredericbarthelet I see, the problem is at part in which fixture engine tries to assign a generated service name to the config. It parses the config and crashes.
While just for fixture setup purpose I would argue, that we can simply not use shorthand syntax. Still I think it's valuable to have support for that, for the sake of testing that short syntax works as expected.
I believe it can be fixed by:
PR's in all those projects are welcome!
fredericbarthelet commentedon Jan 7, 2021
@medikoo I just realized the issue is actually not resolved until a new version of @serverless/test is released with the latest commit updating utils version (https://github.com/serverless/test/commit/85aad008fd5deaa389200bd0cd4b2cea90ebdec0).
Could you release a new version of this package and I'll produce a PR on serverless/serverless to update the @serverlerss/test version ?
medikoo commentedon Jan 8, 2021
Sure, it's released now. Still there's no need to bump version in
serverless, as CI automatically is run against latest version of dependencies and we always bump dependencies prior releasing new version (so it's guaranteed to happen then)