...

Source file src/github.com/go-kit/kit/transport/http/request_response_funcs_test.go

Documentation: github.com/go-kit/kit/transport/http

     1  package http_test
     2  
     3  import (
     4  	"context"
     5  	"net/http/httptest"
     6  	"testing"
     7  
     8  	httptransport "github.com/go-kit/kit/transport/http"
     9  )
    10  
    11  func TestSetHeader(t *testing.T) {
    12  	const (
    13  		key = "X-Foo"
    14  		val = "12345"
    15  	)
    16  	r := httptest.NewRecorder()
    17  	httptransport.SetResponseHeader(key, val)(context.Background(), r)
    18  	if want, have := val, r.Header().Get(key); want != have {
    19  		t.Errorf("want %q, have %q", want, have)
    20  	}
    21  }
    22  
    23  func TestSetContentType(t *testing.T) {
    24  	const contentType = "application/json"
    25  	r := httptest.NewRecorder()
    26  	httptransport.SetContentType(contentType)(context.Background(), r)
    27  	if want, have := contentType, r.Header().Get("Content-Type"); want != have {
    28  		t.Errorf("want %q, have %q", want, have)
    29  	}
    30  }
    31  

View as plain text