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 more tests for v2, v3, and v4 container metadata endpoints #3708

Merged
merged 1 commit into from
May 24, 2023

Conversation

amogh09
Copy link
Contributor

@amogh09 amogh09 commented May 22, 2023

Summary

  • Add more tests for v2, v3, and v4 container metadata endpoints. Currently there are many error cases that are not covered by existing tests. This change fills that gap in coverage.
  • General improvements to the test file.

Implementation details

  • Expected responses for v4 container metadata in task_server_setup_test.go are currently initialized with v2.ContainerResponse.Network field that must be set to nil before the struct is used for assertions. Fix this by setting the field to nil when the struct is initialized.
  • Add a generic testTMDSRequest function that may be used to test happy and error cases of all metadata endpoints. This function removes the need to set up TMDS, setup mocks, perform JSON unmarshalling, and perform assertions in each test function, thus greatly simplifying TMDS testing.
  • Add TestV2ContainerMetadata, TestV3ContainerMetadata, and TestV4ContainerMetadata functions for testing v2, v3, and v4 container metadata endpoints, respectively. These test functions include all happy and error cases. Remove existing tests for these endpoints as they are covered in the new test functions.

Testing

New tests cover the changes: yes

Description for the changelog

Add more tests for v2, v3, and v4 container metadata endpoints

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@amogh09 amogh09 force-pushed the more-metadata-tests branch 2 times, most recently from 4011448 to 5c620e0 Compare May 22, 2023 22:13
@amogh09 amogh09 changed the title Add more tests for v2, v3, and v4 container metadata handlers Add more tests for v2, v3, and v4 container metadata endpoints May 22, 2023
@amogh09 amogh09 marked this pull request as ready for review May 22, 2023 23:34
@amogh09 amogh09 requested a review from a team as a code owner May 22, 2023 23:34
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.

5 participants