Skip to content

Commit

Permalink
Fix director_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
jhiemstrawisc committed Oct 3, 2023
1 parent bf08bd2 commit 655c816
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions director.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package pelican

import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions director_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
}

0 comments on commit 655c816

Please sign in to comment.