mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
7caee1cfbb
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package apiclient
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_parseHeaders(t *testing.T) {
|
|
t.Run("Header parsed successfully", func(t *testing.T) {
|
|
headerString := []string{"foo:", "foo1:bar1", "foo2:bar2:bar2"}
|
|
headers, err := parseHeaders(headerString)
|
|
require.NoError(t, err)
|
|
assert.Empty(t, headers.Get("foo"))
|
|
assert.Equal(t, "bar1", headers.Get("foo1"))
|
|
assert.Equal(t, "bar2:bar2", headers.Get("foo2"))
|
|
})
|
|
|
|
t.Run("Header parsed error", func(t *testing.T) {
|
|
headerString := []string{"foo"}
|
|
_, err := parseHeaders(headerString)
|
|
assert.ErrorContains(t, err, "additional headers must be colon(:)-separated: foo")
|
|
})
|
|
}
|
|
|
|
func Test_parseGRPCHeaders(t *testing.T) {
|
|
t.Run("Header parsed successfully", func(t *testing.T) {
|
|
headerStrings := []string{"origin: https://foo.bar", "content-length: 123"}
|
|
headers, err := parseGRPCHeaders(headerStrings)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []string{" https://foo.bar"}, headers.Get("origin"))
|
|
assert.Equal(t, []string{" 123"}, headers.Get("content-length"))
|
|
})
|
|
|
|
t.Run("Header parsed error", func(t *testing.T) {
|
|
headerString := []string{"foo"}
|
|
_, err := parseGRPCHeaders(headerString)
|
|
assert.ErrorContains(t, err, "additional headers must be colon(:)-separated: foo")
|
|
})
|
|
}
|