Add human-readbale log output (#681)

Add human-readable log output. It prints out the exact source code line information.
This commit is contained in:
Zoltan Papp
2023-02-27 12:20:07 +01:00
committed by GitHub
parent b52afe8d42
commit 9f951c8fb5
6 changed files with 194 additions and 21 deletions
+39
View File
@@ -0,0 +1,39 @@
package formatter
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFilePathParsing(t *testing.T) {
testCases := []struct {
filePath string
expectedFileName string
}{
// locally cloned repo
{
filePath: "/Users/user/Github/Netbird/netbird/formatter/formatter.go",
expectedFileName: "formatter/formatter.go",
},
// locally cloned repo with duplicated name in path
{
filePath: "/Users/user/netbird/repos/netbird/formatter/formatter.go",
expectedFileName: "formatter/formatter.go",
},
// locally cloned repo with renamed package root
{
filePath: "/Users/user/Github/MyOwnNetbirdClient/formatter/formatter.go",
expectedFileName: "formatter/formatter.go",
},
}
hook := NewContextHook()
for _, testCase := range testCases {
parsedString := hook.parseSrc(testCase.filePath)
assert.Equal(t, testCase.expectedFileName, parsedString, "Parsed filepath does not match expected for %s", testCase.filePath)
}
}