You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/transport/http/resolver_test.go

30 lines
896 B

package http
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseTarget(t *testing.T) {
target, err := parseTarget("localhost:8000", false)
assert.Nil(t, err)
assert.Equal(t, &Target{Scheme: "http", Authority: "localhost:8000"}, target)
target, err = parseTarget("discovery:///demo", false)
assert.Nil(t, err)
assert.Equal(t, &Target{Scheme: "discovery", Authority: "", Endpoint: "demo"}, target)
target, err = parseTarget("127.0.0.1:8000", false)
assert.Nil(t, err)
assert.Equal(t, &Target{Scheme: "http", Authority: "127.0.0.1:8000"}, target)
target, err = parseTarget("https://127.0.0.1:8000", false)
assert.Nil(t, err)
assert.Equal(t, &Target{Scheme: "https", Authority: "127.0.0.1:8000"}, target)
target, err = parseTarget("127.0.0.1:8000", true)
assert.Nil(t, err)
assert.Equal(t, &Target{Scheme: "https", Authority: "127.0.0.1:8000"}, target)
}