question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intrinsic function short form usage in integration test fixtures causes fixture loading to fail

See original GitHub issue

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

https://github.com/serverless/serverless/blob/c864fbd4826de27d2796e394b0a100c8d3add33e/test/fixtures/httpApiExport/serverless.yml#L26

However, replacing this with short syntax (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html#ref-declaration) !Ref HttpApi will cause fixture setup to fail.

⚠️⚠️ REPLACE WITH FULL COMMAND NAME output
AWS_ACCESS_KEY_ID=xxxx AWS_SECRET_ACCESS_KEY=xxxx npx mocha test/integration/httpApi.test.js

Installed version

Framework Core: 2.15.0
Plugin: 4.2.0
SDK: 2.3.2
Components: 3.4.3

IMHO, the issue comes from @serverless/test package get-fixtures-engine.js file code block bellow :

try {
  return loadYaml(configContent);
} catch (error) {
  return null;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
medikoocommented, Jan 8, 2021

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)

1reaction
medikoocommented, 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:

  1. Moving lib/plugins/aws/lib/clouformationSchema.js to @serverless/utils package
  2. Parse config with schema option in fixture setup in @servelress/test/get-fixtures-engine

PR’s in all those projects are welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rails 4: Why do fixtures make this test fail? - Stack Overflow
I have the test below and if there are any fixtures for this model it fails with total_unapproved and new_total being equal instead...
Read more >
Testing in Go: Fixtures - Ilija Eftimov ‍
The setup using fixtures is done to satisfy any preconditions there may be for the code under test. For example, code that we...
Read more >
Integration tests in ASP.NET Core | Microsoft Learn
Learn how integration tests ensure that an app's components function correctly at the infrastructure level, including the database, ...
Read more >
FUNCTIONAL TEST SYSTEMS | Intrinsic Quality LLC
Intrinsic Quality delivers turnkey standalone Functional Test fixtures and Windows based functional testers that are custom engineered with innovation and ...
Read more >
can't use fixtures with a created engine · Issue #4971 · rails/rails
i create an engine, and some models, then i started to test, on 'rake test' command i realized that the fixtures are not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found