Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unit Tests for Input Parsing #433

Merged
merged 11 commits into from
Dec 2, 2022
Merged

Add Unit Tests for Input Parsing #433

merged 11 commits into from
Dec 2, 2022

Conversation

guineveresaenger
Copy link
Contributor

This PR cleans up the input verification for Image and adds unit tests.
There are a few minor code changes mostly as a result of adding test cases.

Fixes #420

  • refactor test case declaration
  • Add tests for setRegistry. Harden setRegistry against nil interface values.
  • Add first pass of marshalBuild tests
  • Separate getting args and env into helper functions. Add basic test coverage for both
  • Refactor Registry tests into suite
  • clean up test case declaration for registry
  • Add TestGetCachedImages
  • Do not set empty maps for Args and Env
  • Test ExtraOptions

@github-actions
Copy link

github-actions bot commented Dec 1, 2022

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

return reg
}
return reg
}

func setArgs(a resource.PropertyValue) map[string]*string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why these are called setX? They're pure functions that are doing some marshaling? The set prefix makes me expect they set something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replacing with marshalX - thank you that is a good point!

input := resource.PropertyValue{
resource.NewPropertyMapFromMap(map[string]interface{}{}),
}
actual := marshalBuild(input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly from this test it looks like marshalBuild applies default values. This is a bit unexpected given the name "marshalBuild" the "marshal" part makes me expect something that just does 'boring' conversions between formats. Perhaps "marshalBuildAndApplyDefaults"?

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@github-actions
Copy link

github-actions bot commented Dec 2, 2022

Does the PR have any schema changes?

Looking good! No breaking changes found.
No new resources/functions.

@guineveresaenger guineveresaenger merged commit 8ebdf9c into master Dec 2, 2022
@pulumi-bot pulumi-bot deleted the unit-tests branch December 2, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add unit tests for input parsing
2 participants