From 3e4c01c8bdfd1e66ff6e04b4efba83d7ed21bbd5 Mon Sep 17 00:00:00 2001 From: Slug-Boi Date: Thu, 10 Apr 2025 13:31:01 +0200 Subject: [PATCH] test: fix linux not panic on authorfile test --- src/cmd/utils/util_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cmd/utils/util_test.go b/src/cmd/utils/util_test.go index 8136de6..a3431e0 100644 --- a/src/cmd/utils/util_test.go +++ b/src/cmd/utils/util_test.go @@ -126,20 +126,25 @@ func Test_FindAuthorFilePanic(t *testing.T) { // Save original environment variables originalAuthorFile := os.Getenv("author_file") originalHome := os.Getenv("HOME") + orignalXDG := os.Getenv("XDG_CONFIG_HOME") // Test Find_authorfile panic defer func() { // Reset environment variables os.Setenv("author_file", originalAuthorFile) os.Setenv("HOME", originalHome) + os.Setenv("XDG_CONFIG_HOME", orignalXDG) if r := recover(); r == nil { t.Errorf("Find_authorfile() did not panic") } }() + // Set environment variables to empty strings + // to trigger the panic os.Setenv("author_file", "") os.Setenv("HOME", "") + os.Setenv("XDG_CONFIG_HOME", "") utils.Find_authorfile() }