Files
karma/internal/transform/strip_test.go
Łukasz Mierzwa 5d4ae47888 Convert all packages to be internal
Internal packages are supported by Go 1.5+, any package in /internal/ dir is only importable from the same repo. This will cleanup main dir a bit and provide better namespace for unsee subpackages
2017-08-04 16:21:27 -07:00

72 lines
1.3 KiB
Go

package transform_test
import (
"reflect"
"testing"
"github.com/cloudflare/unsee/internal/transform"
)
type stripTest struct {
strip []string
before map[string]string
after map[string]string
}
var stripTests = []stripTest{
stripTest{
strip: []string{"env"},
before: map[string]string{
"host": "localhost",
"env": "production",
"level": "info",
},
after: map[string]string{
"host": "localhost",
"level": "info",
},
},
stripTest{
strip: []string{"server"},
before: map[string]string{
"host": "localhost",
"env": "production",
"level": "info",
},
after: map[string]string{
"host": "localhost",
"env": "production",
"level": "info",
},
},
stripTest{
strip: []string{},
before: map[string]string{
"host": "localhost",
"env": "production",
"level": "info",
},
after: map[string]string{
"host": "localhost",
"env": "production",
"level": "info",
},
},
stripTest{
strip: []string{"host"},
before: map[string]string{
"host": "localhost",
},
after: map[string]string{},
},
}
func TestStripLables(t *testing.T) {
for _, testCase := range stripTests {
labels := transform.StripLables(testCase.strip, testCase.before)
if !reflect.DeepEqual(labels, testCase.after) {
t.Errorf("StripLables failed, expected %v, got %v", testCase.after, labels)
}
}
}