Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadrad committed Oct 19, 2020
1 parent ca49a2d commit 2c6c8e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions config/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package config

import (
"encoding/json"
"os"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -85,3 +86,16 @@ func TestSetDefault(t *testing.T) {
SetDefault(&vv, 6)
assert.Equal(t, uint(5), vv)
}

func TestGetEnvInt(t *testing.T) {
v := GetEnvInt("NOT_EXIST", 10)
assert.Equal(t, 10, v)

os.Setenv("PANOPTES_TEST", "11")
v = GetEnvInt("TEST", 10)
assert.Equal(t, 11, v)

os.Setenv("PANOPTES_TEST", "CHAR")
v = GetEnvInt("TEST", 10)
assert.Equal(t, 10, v)
}
10 changes: 10 additions & 0 deletions telemetry/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,13 @@ func TestGetValue(t *testing.T) {
assert.Equal(t, row.v, v)
}
}

func TestMergeLabel(t *testing.T) {
kl := map[string]string{"a": "b", "c": "q"}
pl := map[string]string{"a": "b"}
exp := map[string]string{"/prefix/a": "b", "a": "b", "c": "q"}

m := MergeLabels(kl, pl, "/prefix")

assert.Equal(t, exp, m)
}

0 comments on commit 2c6c8e0

Please sign in to comment.