From 655c816527adbffffe2488c8b9b5af8373f630c6 Mon Sep 17 00:00:00 2001 From: Justin Hiemstra Date: Tue, 3 Oct 2023 14:48:26 +0000 Subject: [PATCH] Fix director_test.go --- director.go | 2 ++ director_test.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/director.go b/director.go index 3ac139346..f2a14c31a 100644 --- a/director.go +++ b/director.go @@ -20,6 +20,7 @@ package pelican import ( "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -159,6 +160,7 @@ func QueryDirector(source string, directorUrl string) (resp *http.Response, err // Check HTTP response -- should be 307 (redirect), else something went wrong body, _ := io.ReadAll(resp.Body) if resp.StatusCode != 307 { + fmt.Printf("\n\n\nresp.StatusCode %d\n\n\n", resp.StatusCode) var respErr directorResponse if unmarshalErr := json.Unmarshal(body, &respErr); unmarshalErr != nil { // Error creating json return nil, errors.Wrap(unmarshalErr, "Could not unmarshall the director's response") diff --git a/director_test.go b/director_test.go index db5a09ea5..a39127424 100644 --- a/director_test.go +++ b/director_test.go @@ -188,7 +188,7 @@ func TestQueryDirector(t *testing.T) { expectedLocation := "http://redirect.com" handler := func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Location", expectedLocation) - w.WriteHeader(http.StatusFound) + w.WriteHeader(http.StatusTemporaryRedirect) } server := httptest.NewServer(http.HandlerFunc(handler)) defer server.Close() @@ -206,7 +206,7 @@ func TestQueryDirector(t *testing.T) { } // Check the HTTP status code - if actualResp.StatusCode != http.StatusFound { + if actualResp.StatusCode != http.StatusTemporaryRedirect { t.Errorf("Expected HTTP status code %d, but got %d", http.StatusFound, actualResp.StatusCode) } }