[PR #199] [MERGED] test: add unit tests for pkg/config package #228

Closed
opened 2026-06-06 22:09:48 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vxcontrol/pentagi/pull/199
Author: @mason5052
Created: 3/12/2026
Status: Merged
Merged: 3/20/2026
Merged by: @asdek

Base: feature/next_releaseHead: test/config-package-coverage


📝 Commits (2)

  • 155ceec test: add unit tests for pkg/config package
  • 4cffbe3 Make config tests hermetic against ambient environment variables

📊 Changes

1 file changed (+263 additions, -1 deletions)

View changed files

📝 backend/pkg/config/config_test.go (+263 -1)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vxcontrol/pentagi/pull/199 **Author:** [@mason5052](https://github.com/mason5052) **Created:** 3/12/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@asdek](https://github.com/asdek) **Base:** `feature/next_release` ← **Head:** `test/config-package-coverage` --- ### 📝 Commits (2) - [`155ceec`](https://github.com/vxcontrol/pentagi/commit/155ceec23fc2fd73202508b7f30a2fcf2b9ad2c4) test: add unit tests for pkg/config package - [`4cffbe3`](https://github.com/vxcontrol/pentagi/commit/4cffbe3181928a03d850fab62a4cbfa51220f4ec) Make config tests hermetic against ambient environment variables ### 📊 Changes **1 file changed** (+263 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/pkg/config/config_test.go` (+263 -1) </details> ### 📄 Description ## 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 - [x] Test update - [ ] Documentation update - [ ] Configuration change ## Areas Affected - [x] 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 - [x] Code follows project coding standards - [x] Tests added for changes - [x] All tests pass - [x] `go fmt` and `go vet` run - [x] Changes are backward compatible --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-06 22:09:48 -04:00
yindo closed this issue 2026-06-06 22:09:48 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vxcontrol/pentagi#228