mirror of
https://github.com/Slug-Boi/cocommit.git
synced 2026-05-13 12:45:47 +00:00
test: fix linux not panic on authorfile test
This commit is contained in:
@@ -126,20 +126,25 @@ func Test_FindAuthorFilePanic(t *testing.T) {
|
|||||||
// Save original environment variables
|
// Save original environment variables
|
||||||
originalAuthorFile := os.Getenv("author_file")
|
originalAuthorFile := os.Getenv("author_file")
|
||||||
originalHome := os.Getenv("HOME")
|
originalHome := os.Getenv("HOME")
|
||||||
|
orignalXDG := os.Getenv("XDG_CONFIG_HOME")
|
||||||
|
|
||||||
// Test Find_authorfile panic
|
// Test Find_authorfile panic
|
||||||
defer func() {
|
defer func() {
|
||||||
// Reset environment variables
|
// Reset environment variables
|
||||||
os.Setenv("author_file", originalAuthorFile)
|
os.Setenv("author_file", originalAuthorFile)
|
||||||
os.Setenv("HOME", originalHome)
|
os.Setenv("HOME", originalHome)
|
||||||
|
os.Setenv("XDG_CONFIG_HOME", orignalXDG)
|
||||||
|
|
||||||
if r := recover(); r == nil {
|
if r := recover(); r == nil {
|
||||||
t.Errorf("Find_authorfile() did not panic")
|
t.Errorf("Find_authorfile() did not panic")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// Set environment variables to empty strings
|
||||||
|
// to trigger the panic
|
||||||
os.Setenv("author_file", "")
|
os.Setenv("author_file", "")
|
||||||
os.Setenv("HOME", "")
|
os.Setenv("HOME", "")
|
||||||
|
os.Setenv("XDG_CONFIG_HOME", "")
|
||||||
utils.Find_authorfile()
|
utils.Find_authorfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user