Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package config

import (
"path/filepath"
"testing"
)

func TestEnvironment_LogPath(t *testing.T) {
tests := []struct {
name string
serviceName string
programData string
want string
}{
{
name: "Standard path",
serviceName: "TestService",
programData: "/var/lib",
want: filepath.Join("/var/lib", "TestService", "TestService.log"),
},
Comment on lines +16 to +20

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

This table test repeats several string literals (e.g., "TestService", "/var/lib", "TestService.log") across cases. With goconst enabled in .golangci.yml, this may trigger lint failures; consider extracting shared values into local const/var declarations to keep the test linter-clean and easier to maintain.

Copilot uses AI. Check for mistakes.
{
name: "Empty program data",
serviceName: "TestService",
programData: "",
want: filepath.Join("TestService", "TestService.log"),
},
{
name: "Program data with trailing separator",
serviceName: "TestService",
programData: "/var/lib/",
want: filepath.Join("/var/lib", "TestService", "TestService.log"),
},
{
name: "Service name with spaces",
serviceName: "Test Service",
programData: "/var/lib",
want: filepath.Join("/var/lib", "Test Service", "Test Service.log"),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
e := Environment{
ServiceName: tt.serviceName,
}
Comment on lines +41 to +45

Copilot AI Feb 19, 2026

Copy link

Choose a reason for hiding this comment

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

The subtest closure captures the loop variable tt. This pattern is flagged by govet/loopclosure (and can become a real bug if t.Parallel() is added). Rebind within the loop (e.g., tt := tt) or pass tt as an argument to the closure.

Copilot uses AI. Check for mistakes.
if got := e.LogPath(tt.programData); got != tt.want {
t.Errorf("Environment.LogPath() = %v, want %v", got, tt.want)
}
})
}
}
Loading