Skip to content

Commit

Permalink
fix(config): Correct default value of ident filter
Browse files Browse the repository at this point in the history
  • Loading branch information
heubeck committed Feb 5, 2023
1 parent d222bf0 commit 6e0b274
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var configOptions = map[string][]string{
InfluxMeasurement: {"power"},
MySqlDSN: {"-"},
MySqlTable: {"home_power"},
IdentFilter: {""},
IdentFilter: {"-"},
}

func getUserHome() string {
Expand Down
4 changes: 2 additions & 2 deletions samler.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ func toFilterList(identFilter string) []string {
count := 0
for i, v := range rawIdentFilterList {
tmpIdentFilterList[i] = strings.TrimSpace(v)
if len(tmpIdentFilterList[i]) > 0 {
if len(tmpIdentFilterList[i]) > 0 && tmpIdentFilterList[i] != "-" {
count += 1
}
}
identFilterList := make([]string, count)
i := 0
for _, v := range tmpIdentFilterList {
if len(v) > 0 {
if len(v) > 0 && v != "-" {
identFilterList[i] = v
i += 1
}
Expand Down
4 changes: 2 additions & 2 deletions samler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func TestFailedSending(t *testing.T) {

func TestToEmptyFilterList(t *testing.T) {
// Given
empties := []string{"", " ", ",", " , , "}
empties := []string{"-", "", " ", ",", " , , "}

// When
mapped := [4][]string{}
mapped := [5][]string{}
for i, v := range empties {
mapped[i] = toFilterList(v)
}
Expand Down

0 comments on commit 6e0b274

Please sign in to comment.