internal: fix test on Go 1.10

Go 1.10 no longer sets implicit Content-Type on empty output.

Updates golang/go#20784

Change-Id: I3f13f76b94b58869481218ea2e1805f5f4175fd7
Reviewed-on: https://go-review.googlesource.com/82017
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Brad Fitzpatrick 2017-12-05 22:32:25 +00:00
parent f95fa95eaa
commit ea8c6730ed
1 changed files with 5 additions and 1 deletions

View File

@ -6,6 +6,7 @@ package internal
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"net/url"
@ -32,6 +33,7 @@ func TestRetrieveTokenBustedNoSecret(t *testing.T) {
if got, want := r.FormValue("client_secret"), ""; got != want {
t.Errorf("client_secret = %q; want empty", got)
}
io.WriteString(w, "{}") // something non-empty, required to set a Content-Type in Go 1.10
}))
defer ts.Close()
@ -82,7 +84,9 @@ func TestProviderAuthHeaderWorksDomain(t *testing.T) {
func TestRetrieveTokenWithContexts(t *testing.T) {
const clientID = "client-id"
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "{}") // something non-empty, required to set a Content-Type in Go 1.10
}))
defer ts.Close()
_, err := RetrieveToken(context.Background(), clientID, "", ts.URL, url.Values{})