Skip to content

typoes fix in validator/validate.go and validate_test.go #712

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

Closed
wants to merge 1 commit into from

Conversation

Exar04
Copy link

@Exar04 Exar04 commented Apr 5, 2025

Description

This PR fixes #576

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Copy link

welcome bot commented Apr 5, 2025

Yay, your first pull request! 👍 A contributor will be by to give feedback soon. In the meantime, you can find updates in the #github-notifications channel in the community Slack.
Be sure to double-check that you have signed your commits. Here are instructions for making signing an implicit activity while performing a commit.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @Exar04, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request addresses a few minor issues in the validator package. Specifically, it corrects a typo in validate_test.go, updates the file path for the design schema in validate.go, and removes an unused import and a print statement in validate_test.go. The changes aim to improve the accuracy and maintainability of the validator component.

Highlights

  • Typo Fix: Corrects the typo "Dployment" to "Deployment" in validator/validate_test.go to ensure the test case accurately reflects the intended data type.
  • Schema Path Update: Updates the schema file path in validator/validate.go from schemas/constructs/v1beta1/designs.json to schemas/constructs/v1beta1/design/design.json to point to the correct schema file.
  • Code Cleanup: Removes the unused fmt import and a debugging fmt.Println statement from validator/validate_test.go to improve code cleanliness.

Changelog

  • validator/validate.go
    • Updated schema file path from schemas/constructs/v1beta1/designs.json to schemas/constructs/v1beta1/design/design.json (lines 33 and 35).
  • validator/validate_test.go
    • Removed unused fmt import (line 4).
    • Corrected typo in CatalogDataType from "Dployment" to "Deployment" (line 41).
    • Removed debugging fmt.Println statement (line 75).
    • Corrected typo in test name from "validaion" to "validation" (line 67).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


A schema's path,
Must be correct, or all's lost.
Tests catch the change.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This PR fixes typos in validator/validate.go and validate_test.go. The changes include correcting a typo in a test case and updating the path to the design schema. The code changes are straightforward and address the identified issues.

Summary of Findings

  • Typo correction: The PR corrects a typo in the CatalogDataType field within the test case for catalog data validation. This ensures the test case accurately reflects the expected data type.
  • Schema path update: The PR updates the path to the design schema in validator/validate.go. This ensures the validator uses the correct schema file for design validation.
  • Unnecessary import: The PR removes the unused fmt import from validator/validate_test.go, which helps to keep the code clean and reduces unnecessary dependencies.
  • Typo correction in test name: The PR corrects a typo in the test name from validaion to validation in validator/validate_test.go.
  • Unnecessary print statement: The PR removes the unnecessary fmt.Println(err) statement from validator/validate_test.go.

Merge Readiness

The pull request addresses the identified typos and updates the schema path. The changes are straightforward and improve the code's correctness and clarity. I am unable to directly approve the pull request, and users should have others review and approve this code before merging. I recommend merging this pull request after addressing the review comments.

Comment on lines +33 to +35
file, err := schemas.Schemas.Open("schemas/constructs/v1beta1/design/design.json")
if err != nil {
return utils.ErrReadFile(err, "schemas/constructs/v1beta1/designs.json")
return utils.ErrReadFile(err, "schemas/constructs/v1beta1/design/design.json")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The path to the schema file has been updated. Ensure that the new path schemas/constructs/v1beta1/design/design.json is correct and that the file exists at the specified location. This is a high severity issue because an incorrect path will cause the validator to fail.

Suggested change
file, err := schemas.Schemas.Open("schemas/constructs/v1beta1/design/design.json")
if err != nil {
return utils.ErrReadFile(err, "schemas/constructs/v1beta1/designs.json")
return utils.ErrReadFile(err, "schemas/constructs/v1beta1/design/design.json")
file, err := schemas.Schemas.Open("schemas/constructs/v1beta1/design/design.json")
if err != nil {
return utils.ErrReadFile(err, "schemas/constructs/v1beta1/design/design.json")
}

Comment on lines +40 to 41
Type: v1alpha1.CatalogDataType("Deployment"),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The typo in CatalogDataType("Dployment") has been corrected to CatalogDataType("Deployment"). This is a high severity issue because the typo could cause the test to fail unexpectedly or pass incorrectly.

Suggested change
Type: v1alpha1.CatalogDataType("Deployment"),
},
Type: v1alpha1.CatalogDataType("Deployment"),

Comment on lines +66 to 67
t.Run("validation", func(_t *testing.T) {
schema, err := GetSchemaFor(test.Path)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The typo in the test name validaion has been corrected to validation. This is a medium severity issue because it improves the readability and maintainability of the test code.

Suggested change
t.Run("validation", func(_t *testing.T) {
schema, err := GetSchemaFor(test.Path)
t.Run("validation", func(_t *testing.T) {

Comment on lines 63 to 75
}

for _, test := range tests {
t.Run("validaion", func(_t *testing.T) {
t.Run("validation", func(_t *testing.T) {
schema, err := GetSchemaFor(test.Path)
if err != nil {
t.Errorf("%v", err)

}

err = Validate(schema, test.Resource)
fmt.Println(err)
if test.ShouldPass && err != nil {
t.Errorf("test failed for %s, got %s, want %t, error: %v", test.Path, "false", test.ShouldPass, err)

Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The fmt.Println(err) statement has been removed. This is a medium severity issue because print statements should not be in production code.

	}

		err = Validate(schema, test.Resource)
		if test.ShouldPass && err != nil {

@Exar04 Exar04 closed this Apr 20, 2025
@Exar04 Exar04 deleted the fixingTyposInValidatorTest branch April 20, 2025 04:35
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.

Golang Test Validator Errors
1 participant