Skip to content

Conversation

owenrumney
Copy link
Collaborator

add more tests to improve the quality

Closes #14

@owenrumney owenrumney requested a review from Copilot June 11, 2025 12:36
@owenrumney owenrumney self-assigned this Jun 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds missing tests across multiple packages to boost coverage and introduces a coverage Makefile target.

  • Adds unit tests for tools, scan, mcpserver, flag, commands/auth, and internal/creds packages
  • Introduces a coverage target in the Makefile for HTML report generation

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/tools/tool_test.go Tests for NewTrivyTools and Cleanup methods
pkg/tools/tool.go Refactors AddTools to build a slice before calling s.AddTools
pkg/tools/scan/scan_test.go Tests for NewScanTools and getFilename
pkg/tools/scan/report_test.go Tests for processResultSummary
pkg/mcpserver/mcp_test.go Tests for NewMcpServer
pkg/flag/flag_test.go Tests for flag registration and default values
pkg/commands/auth_test.go Tests for NewAuthCommand, getInput, and getRegionFromList
internal/creds/verify_test.go Comprehensive tests for JWT, HMAC, token logic, URL generation
internal/creds/aqua_test.go Defines skipCI helper
Makefile Adds coverage target for HTML coverage report
Comments suppressed due to low confidence (2)

internal/creds/aqua_test.go:12

  • The skipCI function references os.Getenv and *testing.T but the imports block is missing "os" and "testing". Add these imports to fix the compilation error.
func skipCI(t *testing.T) {

pkg/tools/tool.go:47

  • There are no existing tests covering AddTools. Consider adding unit tests to verify that both scanTools and versionTools are registered with the server under various conditions.
if t.scanTools != nil {

)
var tools []server.ServerTool

if t.scanTools != nil {
Copy link
Preview

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

[nitpick] Since scanTools and versionTools are always initialized in NewTrivyTools, these nil checks are redundant. You could simplify this section by always appending the tools or clarifying the intended optionality.

Copilot uses AI. Check for mistakes.

owenrumney and others added 2 commits June 11, 2025 13:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@owenrumney owenrumney merged commit a65ecfd into main Jun 11, 2025
3 checks passed
@owenrumney owenrumney deleted the test/add-more-test branch June 11, 2025 13:02
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.

test: Work out some sensible tests
1 participant