diff --git a/internal/gomote/gomote.go b/internal/gomote/gomote.go index cb830cbeb8..5bf86abffb 100644 --- a/internal/gomote/gomote.go +++ b/internal/gomote/gomote.go @@ -478,7 +478,7 @@ func (s *Server) WriteFileFromURL(ctx context.Context, req *protos.WriteFileFrom return nil, status.Errorf(codes.Aborted, "failed to get file from URL: %s", err) } if resp.StatusCode != http.StatusOK { - return nil, status.Errorf(codes.Aborted, "unable to get file from URL: response code: %d", resp.StatusCode) + return nil, status.Errorf(codes.Aborted, "unable to get file from %q: response code: %d", req.GetUrl(), resp.StatusCode) } rc = resp.Body } diff --git a/internal/gomote/gomote_test.go b/internal/gomote/gomote_test.go index 440f6238a5..674165e1b4 100644 --- a/internal/gomote/gomote_test.go +++ b/internal/gomote/gomote_test.go @@ -12,6 +12,8 @@ import ( "errors" "fmt" "io" + "net/http" + "net/http/httptest" "testing" "time" @@ -788,9 +790,13 @@ func TestWriteFileFromURL(t *testing.T) { ctx := access.FakeContextWithOutgoingIAPAuth(context.Background(), fakeIAP()) client := setupGomoteTest(t, context.Background()) gomoteID := mustCreateInstance(t, client, fakeIAP()) + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "Go is an open source programming language") + })) + defer ts.Close() if _, err := client.WriteFileFromURL(ctx, &protos.WriteFileFromURLRequest{ GomoteId: gomoteID, - Url: `https://go.dev/dl/go1.17.6.linux-amd64.tar.gz`, + Url: ts.URL, Filename: "foo", Mode: 0777, }); err != nil {