test: add unit test for Header.has (#2555)
Signed-off-by: Guangwen Feng <fenggw-fnst@fujitsu.com>
This commit is contained in:
parent
be6d8085c7
commit
7bc0a0f71e
|
|
@ -19,8 +19,44 @@ package source
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestHeader_has(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
h Header
|
||||||
|
key string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "",
|
||||||
|
h: Header{
|
||||||
|
"aaa": []string{"ddd"}, "fff": []string{"cccc"},
|
||||||
|
},
|
||||||
|
key: "aaa",
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "",
|
||||||
|
h: Header{
|
||||||
|
"aaa": []string{"ddd"}, "fff": []string{"cccc"},
|
||||||
|
},
|
||||||
|
key: "bbb",
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
xx := tt.h.has(tt.key)
|
||||||
|
assert.Equal(tt.want, xx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestHeader_Clone(t *testing.T) {
|
func TestHeader_Clone(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue