mirror of https://github.com/knative/pkg.git
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:
parent
e73c8084c2
commit
84bccfd045
|
@ -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
|
||||
}{{
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"client_id": "123456",
|
||||
"client_secret": "123456",
|
||||
"refresh_token": "123456",
|
||||
"type": "authorized_user"
|
||||
}
|
Loading…
Reference in New Issue