-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved handling of stack trace log file
- Loading branch information
1 parent
3fc3a8b
commit 3520dd4
Showing
7 changed files
with
139 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package provider | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestUnitValidateLogFilePath(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
path interface{} | ||
expectError bool | ||
}{ | ||
{ | ||
name: "Valid log file path", | ||
path: "logs/application.log", | ||
expectError: false, | ||
}, | ||
{ | ||
name: "Empty path", | ||
path: "", | ||
expectError: true, | ||
}, | ||
{ | ||
name: "Non-string value", | ||
path: 123, | ||
expectError: true, | ||
}, | ||
{ | ||
name: "Relative path with directory", | ||
path: "./logs/currentTestCase.log", | ||
expectError: false, | ||
}, | ||
{ | ||
name: "Absolute path", | ||
path: "/var/logs/currentTestCase.log", | ||
expectError: false, | ||
}, | ||
{ | ||
name: "Path with spaces", | ||
path: "logs/current TestCase.log", | ||
expectError: true, | ||
}, | ||
{ | ||
name: "Incorrect file extension", | ||
path: "terraform.tfstate", | ||
expectError: true, | ||
}, | ||
{ | ||
name: "Incorrect file extension", | ||
path: "main.go", | ||
expectError: true, | ||
}, | ||
} | ||
|
||
for _, currentTestCase := range testCases { | ||
t.Run(currentTestCase.name, func(t *testing.T) { | ||
diagErr := validateLogFilePath(currentTestCase.path, nil) | ||
if currentTestCase.expectError && diagErr == nil { | ||
t.Fatalf("Expected an error, but got none") | ||
} | ||
if !currentTestCase.expectError && diagErr != nil { | ||
t.Fatalf("Unexpected error: %v", diagErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters