mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-13 17:07:30 +02:00
Print out the goroutine id (#3433)
The TXT logger prints out the actual go routine ID This feature depends on 'loggoroutine' build tag ```go build -tags loggoroutine```
This commit is contained in:
39
formatter/hook/hook_test.go
Normal file
39
formatter/hook/hook_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package hook
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user