Add fake cred file to make client_test.go independent of gcloud (#963)

* add fake cred file to make the test independent of gcloud

* address comments
This commit is contained in:
Chi Zhang 2019-12-26 13:16:30 -08:00 committed by Knative Prow Robot
parent e73c8084c2
commit 84bccfd045
2 changed files with 17 additions and 1 deletions

View File

@ -17,13 +17,23 @@ limitations under the License.
package gke
import (
"os"
"path/filepath"
"testing"
option "google.golang.org/api/option"
"google.golang.org/api/option"
)
const credEnvKey = "GOOGLE_APPLICATION_CREDENTIALS"
// func NewSDKClient(opts ...option.ClientOption) (SDKOperations, error) {
func TestNewSDKClient(t *testing.T) {
pwd, _ := os.Getwd()
if err := os.Setenv(credEnvKey, filepath.Join(pwd, "fake/credentials.json")); err != nil {
t.Errorf("Failed to set %s to fake/credentials.json: %v", credEnvKey, err)
}
defer os.Unsetenv(credEnvKey)
datas := []struct {
req option.ClientOption
}{{

View File

@ -0,0 +1,6 @@
{
"client_id": "123456",
"client_secret": "123456",
"refresh_token": "123456",
"type": "authorized_user"
}