test: add unit test for Header.has (#2555)

Signed-off-by: Guangwen Feng <fenggw-fnst@fujitsu.com>
This commit is contained in:
Guangwen Feng 2023-07-19 16:56:49 +08:00 committed by GitHub
parent be6d8085c7
commit 7bc0a0f71e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 0 deletions

View File

@ -19,8 +19,44 @@ package source
import (
"fmt"
"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) {
tests := []struct {
name string