diff --git a/kms/kms_test.go b/kms/kms_test.go index 9b041e59..f377072f 100644 --- a/kms/kms_test.go +++ b/kms/kms_test.go @@ -2,6 +2,7 @@ package kms import ( "context" + "os" "reflect" "testing" @@ -18,20 +19,25 @@ func TestNew(t *testing.T) { opts apiv1.Options } tests := []struct { - name string - args args - want KeyManager - wantErr bool + name string + skipOnCI bool + args args + want KeyManager + wantErr bool }{ - {"softkms", args{ctx, apiv1.Options{Type: "softkms"}}, &softkms.SoftKMS{}, false}, - {"default", args{ctx, apiv1.Options{}}, &softkms.SoftKMS{}, false}, - {"cloudkms", args{ctx, apiv1.Options{Type: "cloudkms"}}, &cloudkms.CloudKMS{}, true}, // fails because not credentials - {"awskms", args{ctx, apiv1.Options{Type: "awskms"}}, nil, true}, // not yet supported - {"pkcs11", args{ctx, apiv1.Options{Type: "pkcs11"}}, nil, true}, // not yet supported - {"fail validation", args{ctx, apiv1.Options{Type: "foobar"}}, nil, true}, + {"softkms", false, args{ctx, apiv1.Options{Type: "softkms"}}, &softkms.SoftKMS{}, false}, + {"default", false, args{ctx, apiv1.Options{}}, &softkms.SoftKMS{}, false}, + {"cloudkms", true, args{ctx, apiv1.Options{Type: "cloudkms"}}, &cloudkms.CloudKMS{}, true}, // fails because not credentials + {"awskms", false, args{ctx, apiv1.Options{Type: "awskms"}}, nil, true}, // not yet supported + {"pkcs11", false, args{ctx, apiv1.Options{Type: "pkcs11"}}, nil, true}, // not yet supported + {"fail validation", false, args{ctx, apiv1.Options{Type: "foobar"}}, nil, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + if tt.skipOnCI && os.Getenv("CI") == "true" { + t.SkipNow() + } + got, err := New(tt.args.ctx, tt.args.opts) if (err != nil) != tt.wantErr { t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr)