mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
cloud: don't require application default credentials to run unit tests
This commit is contained in:
parent
c7414323d8
commit
a9e0a2b09a
@ -18,6 +18,7 @@ package gce
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -261,13 +262,16 @@ var apiService = &v1.Service{
|
||||
},
|
||||
}
|
||||
|
||||
func fakeGCECloud() (*GCECloud, error) {
|
||||
client, err := newOauthClient(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
type fakeRoundTripper struct{}
|
||||
|
||||
service, err := compute.New(client)
|
||||
func (*fakeRoundTripper) RoundTrip(*http.Request) (*http.Response, error) {
|
||||
return nil, fmt.Errorf("err: test used fake http client")
|
||||
}
|
||||
|
||||
func fakeGCECloud() (*GCECloud, error) {
|
||||
c := &http.Client{Transport: &fakeRoundTripper{}}
|
||||
|
||||
service, err := compute.New(c)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user