-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alexferl <me@alexferl.com>
- Loading branch information
Showing
18 changed files
with
332 additions
and
534 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Test and coverage | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.22' | ||
- name: Run coverage | ||
run: go test -race -coverprofile=coverage.out -covermode=atomic | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 |
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ _testmain.go | |
*.test | ||
*.prof | ||
|
||
*.out | ||
*.log | ||
.idea | ||
tinysyslog-bin |
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
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,29 @@ | ||
package constants | ||
|
||
const ( | ||
MutatorText = "text" | ||
MutatorJSON = "json" | ||
) | ||
|
||
var Mutators = []string{MutatorText, MutatorJSON} | ||
|
||
const ( | ||
FilterRegex = "regex" | ||
) | ||
|
||
var Filters = []string{FilterRegex} | ||
|
||
const ( | ||
SinkConsole = "console" | ||
SinkElasticsearch = "elasticsearch" | ||
SinkFilesystem = "filesystem" | ||
) | ||
|
||
var Sinks = []string{SinkConsole, SinkElasticsearch, SinkFilesystem} | ||
|
||
const ( | ||
ConsoleStdOut = "stdout" | ||
ConsoleStdErr = "stderr" | ||
) | ||
|
||
var ConsoleOutputs = []string{ConsoleStdOut, ConsoleStdErr} |
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,16 @@ | ||
package filters | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNoOp(t *testing.T) { | ||
msg := `<165>1 2016-01-01T12:01:21Z hostname appname 1234 ID47 [exampleSDID@32473 iut="9" eventSource="test" eventID="123"] message"` | ||
|
||
f := NewNoOp() | ||
s, err := f.Filter(msg) | ||
assert.NoError(t, err) | ||
assert.Equal(t, msg, s) | ||
} |
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,36 @@ | ||
package filters | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestRegex(t *testing.T) { | ||
msg := `<165>1 2016-01-01T12:01:21Z hostname appname 1234 ID47 [exampleSDID@32473 iut="9" eventSource="test" eventID="123"] message"` | ||
|
||
testCases := []struct { | ||
name string | ||
re string | ||
res string | ||
err bool | ||
}{ | ||
{"match", "appname", "", false}, | ||
{"no match", "xyz", msg, false}, | ||
{"no regex", "", msg, false}, | ||
{"invalid regex", "(?=\"", "", true}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
f := NewRegex(tc.re) | ||
s, err := f.Filter(msg) | ||
if tc.err { | ||
assert.Error(t, err) | ||
} else { | ||
assert.NoError(t, err) | ||
assert.Equal(t, tc.res, s) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.