From f14be8949d7f71408f763d65a6cd8663c4cf4443 Mon Sep 17 00:00:00 2001 From: adcondev <38170282+adcondev@users.noreply.github.com> Date: Thu, 19 Feb 2026 20:23:57 +0000 Subject: [PATCH] Add tests for LogPath in config package Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- internal/config/config_test.go | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 internal/config/config_test.go diff --git a/internal/config/config_test.go b/internal/config/config_test.go new file mode 100644 index 0000000..aa060ca --- /dev/null +++ b/internal/config/config_test.go @@ -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"), + }, + { + 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, + } + if got := e.LogPath(tt.programData); got != tt.want { + t.Errorf("Environment.LogPath() = %v, want %v", got, tt.want) + } + }) + } +}