Skip to content

test: add unit tests for pkg/config package#199

Merged
asdek merged 2 commits intovxcontrol:feature/next_releasefrom
mason5052:test/config-package-coverage
Mar 20, 2026
Merged

test: add unit tests for pkg/config package#199
asdek merged 2 commits intovxcontrol:feature/next_releasefrom
mason5052:test/config-package-coverage

Conversation

@mason5052
Copy link
Copy Markdown
Contributor

Description of Change

Problem: The pkg/config package has no unit test coverage. This package handles all environment variable parsing, default values, URL parsing, and installation ID management for the entire application.

Solution: Add 14 unit tests covering NewConfig defaults, environment variable overrides, URL parsing, provider server URL defaults, summarizer settings, search engine defaults, and all ensureInstallationID code paths (UUID generation, file read/write, invalid value handling).

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Security update
  • Test update
  • Documentation update
  • Configuration change

Areas Affected

  • Core Services (Frontend UI / Backend API)
  • AI Agents (Researcher / Developer / Executor)
  • Security Tools Integration
  • Memory System (Vector Store / Knowledge Base)
  • Monitoring Stack (Grafana / OpenTelemetry)
  • Analytics & Reporting
  • External Integrations (LLM Providers / Search Engines / Security APIs)
  • Documentation
  • Infrastructure / DevOps

Testing and Verification

Test Configuration

  • PentAGI Version: v1.2.0 (master)
  • Go Version: 1.24.1
  • Host OS: Windows 11

Test Steps

  1. Run go test ./pkg/config/... -v

Test Results

=== RUN   TestNewConfig_Defaults
--- PASS: TestNewConfig_Defaults (0.00s)
=== RUN   TestNewConfig_EnvOverride
--- PASS: TestNewConfig_EnvOverride (0.00s)
=== RUN   TestNewConfig_ProviderDefaults
--- PASS: TestNewConfig_ProviderDefaults (0.00s)
=== RUN   TestNewConfig_StaticURL
--- PASS: TestNewConfig_StaticURL (0.00s)
=== RUN   TestNewConfig_StaticURL_Empty
--- PASS: TestNewConfig_StaticURL_Empty (0.00s)
=== RUN   TestNewConfig_SummarizerDefaults
--- PASS: TestNewConfig_SummarizerDefaults (0.00s)
=== RUN   TestNewConfig_SearchEngineDefaults
--- PASS: TestNewConfig_SearchEngineDefaults (0.00s)
=== RUN   TestEnsureInstallationID_GeneratesNewUUID
--- PASS: TestEnsureInstallationID_GeneratesNewUUID (0.02s)
=== RUN   TestEnsureInstallationID_ReadsExistingFile
--- PASS: TestEnsureInstallationID_ReadsExistingFile (0.01s)
=== RUN   TestEnsureInstallationID_KeepsValidEnvValue
--- PASS: TestEnsureInstallationID_KeepsValidEnvValue (0.00s)
=== RUN   TestEnsureInstallationID_ReplacesInvalidEnvValue
--- PASS: TestEnsureInstallationID_ReplacesInvalidEnvValue (0.00s)
=== RUN   TestEnsureInstallationID_ReplacesInvalidFileContent
--- PASS: TestEnsureInstallationID_ReplacesInvalidFileContent (0.01s)
=== RUN   TestNewConfig_CorsOrigins
--- PASS: TestNewConfig_CorsOrigins (0.00s)
=== RUN   TestNewConfig_OllamaDefaults
--- PASS: TestNewConfig_OllamaDefaults (0.00s)
PASS
ok  	pentagi/pkg/config	3.855s

Checklist

  • Code follows project coding standards
  • Tests added for changes
  • All tests pass
  • go fmt and go vet run
  • Changes are backward compatible

Copilot AI review requested due to automatic review settings March 12, 2026 17:56
Copy link
Copy Markdown

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

Adds initial unit test coverage for backend/pkg/config, focusing on NewConfig() default/env parsing behavior and ensureInstallationID() persistence/validation behavior.

Changes:

  • Add unit tests for NewConfig() defaults and selected env var overrides (URLs, provider defaults, summarizer/search defaults, CORS, Ollama).
  • Add unit tests for ensureInstallationID() covering generation, reading existing IDs, and invalid-value replacement paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/pkg/config/config_test.go Outdated
Add comprehensive unit tests for NewConfig defaults, environment variable
overrides, URL parsing, provider server URL defaults, summarizer defaults,
search engine defaults, and ensureInstallationID logic including UUID
generation, file persistence, and invalid value handling.
Add clearConfigEnv helper that clears all Config struct env vars via
t.Setenv, and use t.Chdir(t.TempDir()) to isolate filesystem side
effects from godotenv.Load() and ensureInstallationID(). Tests now
pass regardless of environment variables set in the calling shell.
@mason5052 mason5052 force-pushed the test/config-package-coverage branch from f9c19d9 to 4cffbe3 Compare March 19, 2026 21:38
@asdek asdek changed the base branch from master to feature/next_release March 20, 2026 19:22
@asdek asdek merged commit f245ed2 into vxcontrol:feature/next_release Mar 20, 2026
@asdek
Copy link
Copy Markdown
Contributor

asdek commented Mar 20, 2026

thank you for the PR!

@asdek asdek mentioned this pull request Mar 22, 2026
36 tasks
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.

3 participants