Files
github--github-mcp-server/pkg/http/headers/parse_test.go
Adam Holt aa302209b0 Add Streamable HTTP mode (#1849)
Adds new `http` command supporting Streamable HTTP support, OAuth Metadata handler and Scope filtering.

Co-authored-by: kerobbi <kerobbi@github.com>
Co-authored-by: Matt Holloway <mattdholloway@github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-06 15:33:41 +01:00

59 lines
1.1 KiB
Go

package headers
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseCommaSeparated(t *testing.T) {
tests := []struct {
name string
input string
expected []string
}{
{
name: "empty string",
input: "",
expected: []string{},
},
{
name: "single value",
input: "foo",
expected: []string{"foo"},
},
{
name: "multiple values",
input: "foo,bar,baz",
expected: []string{"foo", "bar", "baz"},
},
{
name: "whitespace trimmed",
input: " foo , bar , baz ",
expected: []string{"foo", "bar", "baz"},
},
{
name: "empty values filtered",
input: "foo,,bar,",
expected: []string{"foo", "bar"},
},
{
name: "only commas",
input: ",,,",
expected: []string{},
},
{
name: "whitespace only values filtered",
input: "foo, ,bar",
expected: []string{"foo", "bar"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := ParseCommaSeparated(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}