Skip to content

test: add unit tests for labels package and update Makefile for go li…#19

Merged
iasthc merged 2 commits intomainfrom
fix-test
Feb 28, 2026
Merged

test: add unit tests for labels package and update Makefile for go li…#19
iasthc merged 2 commits intomainfrom
fix-test

Conversation

@iasthc
Copy link
Member

@iasthc iasthc commented Feb 28, 2026

…st command

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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!

This pull request enhances the project's testing infrastructure by introducing dedicated unit tests for the labels package, ensuring the reliability of Kubernetes label generation. Concurrently, it refines the Makefile to optimize test execution by excluding non-essential directories and improves Go module version retrieval by explicitly disabling Go workspaces, contributing to a more robust and efficient development workflow.

Highlights

  • New Unit Tests: Added comprehensive unit tests for the internal/labels package to ensure the Standard function correctly generates Kubernetes labels, covering various scenarios including argument passing and fixed label values.
  • Makefile Updates for Testing: Modified the Makefile's test target to exclude cmd and test directories from go test runs, streamlining the test execution process.
  • Makefile Updates for Go Module Versioning: Updated the gomodver definition in the Makefile to explicitly set GOWORK=off when using go list -m, preventing issues with Go workspaces during module version retrieval.
Changelog
  • Makefile
    • Updated the test target to filter out cmd and test directories from go test command.
    • Added GOWORK=off to the gomodver definition to ensure correct Go module version listing.
  • internal/labels/labels_test.go
    • Added new unit tests for the labels.Standard function, verifying its behavior for various inputs and expected outputs.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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.

@codecov
Copy link

codecov bot commented Feb 28, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Copy link

@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 pull request adds unit tests for the labels package and updates the Makefile. No security vulnerabilities were found. The Makefile changes exclude additional directories from the test command and add GOWORK=off to a go list command for robustness. A suggestion has been made to improve map comparison in TestStandard by using reflect.DeepEqual for more idiomatic and robust testing.

Comment on lines 36 to 46
if len(got) != len(want) {
t.Errorf("Standard() returned %d labels, want %d", len(got), len(want))
}

for key, wantVal := range want {
if gotVal, ok := got[key]; !ok {
t.Errorf("Standard() missing label %q", key)
} else if gotVal != wantVal {
t.Errorf("Standard()[%q] = %q, want %q", key, gotVal, wantVal)
}
}

Choose a reason for hiding this comment

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

medium

For comparing maps, using reflect.DeepEqual is more idiomatic and robust in Go tests. It provides a concise way to check for equality and also ensures that there are no extra keys in the got map, which the current implementation doesn't check for. This will make the test cleaner and more reliable.

You will need to add import "reflect" to use this.

Suggested change
if len(got) != len(want) {
t.Errorf("Standard() returned %d labels, want %d", len(got), len(want))
}
for key, wantVal := range want {
if gotVal, ok := got[key]; !ok {
t.Errorf("Standard() missing label %q", key)
} else if gotVal != wantVal {
t.Errorf("Standard()[%q] = %q, want %q", key, gotVal, wantVal)
}
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Standard() = %v, want %v", got, want)
}

…eadability and structure; update labels package to use constants for fixed values
@iasthc iasthc merged commit f426922 into main Feb 28, 2026
11 checks passed
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.

1 participant