forked from pcarleton/sheets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
39 lines (34 loc) · 1.08 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package sheets
import (
"strings"
"testing"
)
var configTests = []struct {
config string
errExpected bool
}{
{"{}", true},
{`{
"type": "service_account",
"project_id": "testproject-123456",
"private_key_id": "abcdef",
"private_key": "-----BEGIN PRIVATE KEY-----\nnotarealkey\n-----END PRIVATE KEY-----\n",
"client_email": "[email protected]",
"client_id": "115842414406405072982",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/robot%40testproject-123456.iam.gserviceaccount.com"
}`, false},
}
func TestNewServiceAccountClient(t *testing.T) {
for _, tt := range configTests {
_, err := NewServiceAccountClientFromReader(strings.NewReader(tt.config))
if tt.errExpected && err == nil {
t.Error("Expected error, but got none")
}
if !tt.errExpected && err != nil {
t.Errorf("Unexpected error: %v", err)
}
}
}