Update option property.

This commit is contained in:
Mariano Cano 2020-10-19 18:47:36 -07:00
parent 9f21813dd6
commit 2654231c49
2 changed files with 8 additions and 8 deletions

View file

@ -70,7 +70,7 @@ var newCertificateAuthorityClient = func(ctx context.Context, credentialsFile st
// New creates a new CertificateAuthorityService implementation using Google // New creates a new CertificateAuthorityService implementation using Google
// Cloud CAS. // Cloud CAS.
func New(ctx context.Context, opts apiv1.Options) (*CloudCAS, error) { func New(ctx context.Context, opts apiv1.Options) (*CloudCAS, error) {
if opts.Certificateauthority == "" { if opts.CertificateAuthority == "" {
return nil, errors.New("cloudCAS 'certificateAuthority' cannot be empty") return nil, errors.New("cloudCAS 'certificateAuthority' cannot be empty")
} }
@ -81,7 +81,7 @@ func New(ctx context.Context, opts apiv1.Options) (*CloudCAS, error) {
return &CloudCAS{ return &CloudCAS{
client: client, client: client,
certificateAuthority: opts.Certificateauthority, certificateAuthority: opts.CertificateAuthority,
}, nil }, nil
} }

View file

@ -174,20 +174,20 @@ func TestNew(t *testing.T) {
wantErr bool wantErr bool
}{ }{
{"ok", args{context.Background(), apiv1.Options{ {"ok", args{context.Background(), apiv1.Options{
Certificateauthority: testAuthorityName, CertificateAuthority: testAuthorityName,
}}, &CloudCAS{ }}, &CloudCAS{
client: &testClient{}, client: &testClient{},
certificateAuthority: testAuthorityName, certificateAuthority: testAuthorityName,
}, false}, }, false},
{"ok with credentials", args{context.Background(), apiv1.Options{ {"ok with credentials", args{context.Background(), apiv1.Options{
Certificateauthority: testAuthorityName, CredentialsFile: "testdata/credentials.json", CertificateAuthority: testAuthorityName, CredentialsFile: "testdata/credentials.json",
}}, &CloudCAS{ }}, &CloudCAS{
client: &testClient{credentialsFile: "testdata/credentials.json"}, client: &testClient{credentialsFile: "testdata/credentials.json"},
certificateAuthority: testAuthorityName, certificateAuthority: testAuthorityName,
}, false}, }, false},
{"fail certificate authority", args{context.Background(), apiv1.Options{}}, nil, true}, {"fail certificate authority", args{context.Background(), apiv1.Options{}}, nil, true},
{"fail with credentials", args{context.Background(), apiv1.Options{ {"fail with credentials", args{context.Background(), apiv1.Options{
Certificateauthority: testAuthorityName, CredentialsFile: "testdata/error.json", CertificateAuthority: testAuthorityName, CredentialsFile: "testdata/error.json",
}}, nil, true}, }}, nil, true},
} }
for _, tt := range tests { for _, tt := range tests {
@ -225,7 +225,7 @@ func TestNew_register(t *testing.T) {
} }
got, err := newFn(context.Background(), apiv1.Options{ got, err := newFn(context.Background(), apiv1.Options{
Certificateauthority: testAuthorityName, CredentialsFile: "testdata/credentials.json", CertificateAuthority: testAuthorityName, CredentialsFile: "testdata/credentials.json",
}) })
if err != nil { if err != nil {
t.Errorf("New() error = %v", err) t.Errorf("New() error = %v", err)
@ -255,10 +255,10 @@ func TestNew_real(t *testing.T) {
args args args args
wantErr bool wantErr bool
}{ }{
{"fail default credentials", true, args{context.Background(), apiv1.Options{Certificateauthority: testAuthorityName}}, true}, {"fail default credentials", true, args{context.Background(), apiv1.Options{CertificateAuthority: testAuthorityName}}, true},
{"fail certificate authority", false, args{context.Background(), apiv1.Options{}}, true}, {"fail certificate authority", false, args{context.Background(), apiv1.Options{}}, true},
{"fail with credentials", false, args{context.Background(), apiv1.Options{ {"fail with credentials", false, args{context.Background(), apiv1.Options{
Certificateauthority: testAuthorityName, CredentialsFile: "testdata/missing.json", CertificateAuthority: testAuthorityName, CredentialsFile: "testdata/missing.json",
}}, true}, }}, true},
} }
for _, tt := range tests { for _, tt := range tests {