2020-07-27 15:22:00 +03:00
|
|
|
package mucp
|
2018-04-14 20:06:52 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2020-07-27 15:22:00 +03:00
|
|
|
|
2020-08-19 17:47:17 +03:00
|
|
|
"github.com/unistack-org/micro/v3/client"
|
2018-04-14 20:06:52 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRequestOptions(t *testing.T) {
|
2019-01-11 00:25:31 +03:00
|
|
|
r := newRequest("service", "endpoint", nil, "application/json")
|
2018-04-14 20:06:52 +03:00
|
|
|
if r.Service() != "service" {
|
|
|
|
t.Fatalf("expected 'service' got %s", r.Service())
|
|
|
|
}
|
2019-01-11 00:25:31 +03:00
|
|
|
if r.Endpoint() != "endpoint" {
|
|
|
|
t.Fatalf("expected 'endpoint' got %s", r.Endpoint())
|
2018-04-14 20:06:52 +03:00
|
|
|
}
|
|
|
|
if r.ContentType() != "application/json" {
|
2019-01-11 00:25:31 +03:00
|
|
|
t.Fatalf("expected 'endpoint' got %s", r.ContentType())
|
2018-04-14 20:06:52 +03:00
|
|
|
}
|
|
|
|
|
2020-07-27 15:22:00 +03:00
|
|
|
r2 := newRequest("service", "endpoint", nil, "application/json", client.WithContentType("application/protobuf"))
|
2018-04-14 20:06:52 +03:00
|
|
|
if r2.ContentType() != "application/protobuf" {
|
2019-01-11 00:25:31 +03:00
|
|
|
t.Fatalf("expected 'endpoint' got %s", r2.ContentType())
|
2018-04-14 20:06:52 +03:00
|
|
|
}
|
|
|
|
}
|