-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
425 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/sofar | ||
sofar_g3_lsw3_logger_reader | ||
/bin | ||
config.yaml | ||
sofar | ||
sofar-x86 | ||
sofar-arm | ||
.idea | ||
.vscode | ||
.idea |
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
all: build-arm build-x86 | ||
|
||
build-arm: | ||
env GOOS=linux GOARCH=arm GOARM=5 go build -o sofar-arm | ||
env GOOS=linux GOARCH=arm GOARM=5 go build -o bin/sofar-arm | ||
|
||
build: | ||
go build -o sofar | ||
go build -o bin/sofar-x86 | ||
|
||
test: | ||
go test -v ./... |
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,49 @@ | ||
package sofar | ||
|
||
import ( | ||
"testing" | ||
"regexp" | ||
) | ||
|
||
func TestNameFilter(t *testing.T) { | ||
// Create a Logger instance with the desired attributes | ||
logger := &Logger{ | ||
attrWhiteList: map[string]struct{}{ | ||
"whitelisted": {}, | ||
}, | ||
attrBlackList: []*regexp.Regexp{ | ||
regexp.MustCompile("^blacklisted"), | ||
}, | ||
} | ||
|
||
// Test case 1: Key in the white list | ||
result := logger.nameFilter("whitelisted") | ||
if result != true { | ||
t.Errorf("Expected: true, Got: %v", result) | ||
} | ||
|
||
// Test case 2: Key not in the white list, but not matching any black list regex | ||
result = logger.nameFilter("notblacklisted") | ||
if result != true { | ||
t.Errorf("Expected: true, Got: %v", result) | ||
} | ||
|
||
// Test case 3: Key in the black list | ||
result = logger.nameFilter("blacklisted-key") | ||
if result != false { | ||
t.Errorf("Expected: false, Got: %v", result) | ||
} | ||
|
||
// Test case 4: Key not in the white list and matches a black list regex | ||
result = logger.nameFilter("blacklisted") | ||
if result != false { | ||
t.Errorf("Expected: false, Got: %v", result) | ||
} | ||
|
||
// Test case 5: No white or black list | ||
logger = &Logger{} // Reset the logger | ||
result = logger.nameFilter("anykey") | ||
if result != true { | ||
t.Errorf("Expected: true, Got: %v", result) | ||
} | ||
} |
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
Oops, something went wrong.