mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
package transform_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/cloudflare/unsee/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)
|
|
}
|
|
}
|
|
}
|