Unverified Commit 202ef1e6 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #60103 from mikedanese/fix-test

Automatic merge from submit-queue (batch tested with PRs 59934, 60098, 60103, 60104, 60109). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. cloud: don't require application default credentials to run unit tests Introduced in https://github.com/kubernetes/kubernetes/pull/59490 ```release-note NONE ```
parents 36f824b6 a9e0a2b0
...@@ -18,6 +18,7 @@ package gce ...@@ -18,6 +18,7 @@ package gce
import ( import (
"fmt" "fmt"
"net/http"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
...@@ -261,13 +262,16 @@ var apiService = &v1.Service{ ...@@ -261,13 +262,16 @@ var apiService = &v1.Service{
}, },
} }
type fakeRoundTripper struct{}
func (*fakeRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
return nil, fmt.Errorf("err: test used fake http client")
}
func fakeGCECloud() (*GCECloud, error) { func fakeGCECloud() (*GCECloud, error) {
client, err := newOauthClient(nil) c := &http.Client{Transport: &fakeRoundTripper{}}
if err != nil {
return nil, err
}
service, err := compute.New(client) service, err := compute.New(c)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment