refactor: co-locate logging, manifest, network, privacy, prommetrics tests

Move unit tests from tests/unit/ to internal/ following Go conventions:
- tests/unit/logging/* -> internal/logging/* (logging tests)
- tests/unit/manifest/* -> internal/manifest/* (run_manifest, schema tests)
- tests/unit/network/* -> internal/network/* (retry, ssh_pool, ssh tests)
- tests/unit/privacy/* -> internal/privacy/* (pii tests)
- tests/unit/metrics/* -> internal/prommetrics/* (metrics tests)

Update import paths in test files to reflect new locations.

Note: metrics_test.go moved from tests/unit/metrics/ to internal/prommetrics/ to match the actual package name.
This commit is contained in:
Jeremie Fraeys 2026-03-12 16:35:37 -04:00
parent cf84246115
commit ca6ad970c3
No known key found for this signature in database
8 changed files with 12 additions and 12 deletions

View file

@ -1,4 +1,4 @@
package tests
package logging_test
import (
"context"

View file

@ -1,4 +1,4 @@
package manifest
package manifest_test
import (
"crypto/sha256"
@ -19,7 +19,7 @@ func TestSchemaUnchanged(t *testing.T) {
// Get the project root (this test runs from internal/manifest/)
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
// Load the committed schema
committedSchemaData, err := os.ReadFile(schemaPath)
@ -65,7 +65,7 @@ func TestSchemaUnchanged(t *testing.T) {
func TestSchemaValidatesExampleManifest(t *testing.T) {
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
schemaLoader, err := loadSchemaFromFile(schemaPath)
if err != nil {
@ -124,7 +124,7 @@ func TestSchemaValidatesExampleManifest(t *testing.T) {
func TestSchemaRejectsInvalidManifest(t *testing.T) {
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
schemaLoader, err := loadSchemaFromFile(schemaPath)
if err != nil {
@ -228,7 +228,7 @@ func TestSchemaVersionMatchesConst(t *testing.T) {
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
// Schema is in internal/manifest, not tests/unit/manifest
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
schemaData, err := os.ReadFile(schemaPath)
if err != nil {
@ -274,7 +274,7 @@ func GenerateSchemaFromStructs() map[string]any {
// Since we have the schema committed, we just return it parsed
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
data, err := os.ReadFile(schemaPath)
if err != nil {
@ -302,7 +302,7 @@ func GenerateSchemaFromStructs() map[string]any {
func GenerateSchemaJSON() []byte {
_, testFile, _, _ := runtime.Caller(0)
testDir := filepath.Dir(testFile)
schemaPath := filepath.Join(testDir, "..", "..", "..", "internal", "manifest", "schema.json")
schemaPath := filepath.Join(testDir, "schema.json")
data, err := os.ReadFile(schemaPath)
if err != nil {

View file

@ -1,4 +1,4 @@
package tests
package network_test
import (
"context"

View file

@ -1,4 +1,4 @@
package tests
package network_test
import (
"context"

View file

@ -1,4 +1,4 @@
package tests
package network_test
import (
"context"

View file

@ -1,4 +1,4 @@
package tests
package prommetrics_test
import (
"testing"