@@ -20,17 +20,16 @@ import (
20
20
"reflect"
21
21
"testing"
22
22
23
- crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
24
23
v1 "k8s.io/api/core/v1"
25
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26
24
)
27
25
28
26
func TestGetSnapshotSecretReference (t * testing.T ) {
29
27
testcases := map [string ]struct {
30
28
secretParams SecretParamsMap
31
29
params map [string ]string
32
30
snapContentName string
33
- snapshot * crdv1.VolumeSnapshot
31
+ snapNamespace string
32
+ snapName string
34
33
expectRef * v1.SecretReference
35
34
expectErr bool
36
35
}{
@@ -45,17 +44,19 @@ func TestGetSnapshotSecretReference(t *testing.T) {
45
44
expectErr : true ,
46
45
},
47
46
"simple - valid" : {
48
- secretParams : SnapshotterSecretParams ,
49
- params : map [string ]string {prefixedSnapshotterSecretNameKey : "name" , prefixedSnapshotterSecretNamespaceKey : "ns" },
50
- snapshot : & crdv1.VolumeSnapshot {},
51
- expectRef : & v1.SecretReference {Name : "name" , Namespace : "ns" },
47
+ secretParams : SnapshotterSecretParams ,
48
+ params : map [string ]string {prefixedSnapshotterSecretNameKey : "name" , prefixedSnapshotterSecretNamespaceKey : "ns" },
49
+ snapNamespace : "" ,
50
+ snapName : "" ,
51
+ expectRef : & v1.SecretReference {Name : "name" , Namespace : "ns" },
52
52
},
53
53
"simple - invalid name" : {
54
- secretParams : SnapshotterSecretParams ,
55
- params : map [string ]string {prefixedSnapshotterSecretNameKey : "bad name" , prefixedSnapshotterSecretNamespaceKey : "ns" },
56
- snapshot : & crdv1.VolumeSnapshot {},
57
- expectRef : nil ,
58
- expectErr : true ,
54
+ secretParams : SnapshotterSecretParams ,
55
+ params : map [string ]string {prefixedSnapshotterSecretNameKey : "bad name" , prefixedSnapshotterSecretNamespaceKey : "ns" },
56
+ snapNamespace : "" ,
57
+ snapName : "" ,
58
+ expectRef : nil ,
59
+ expectErr : true ,
59
60
},
60
61
"template - invalid" : {
61
62
secretParams : SnapshotterSecretParams ,
@@ -64,21 +65,16 @@ func TestGetSnapshotSecretReference(t *testing.T) {
64
65
prefixedSnapshotterSecretNamespaceKey : "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}" ,
65
66
},
66
67
snapContentName : "snapcontentname" ,
67
- snapshot : & crdv1.VolumeSnapshot {
68
- ObjectMeta : metav1.ObjectMeta {
69
- Name : "snapshotname" ,
70
- Namespace : "snapshotnamespace" ,
71
- Annotations : map [string ]string {"akey" : "avalue" },
72
- },
73
- },
74
- expectRef : nil ,
75
- expectErr : true ,
68
+ snapNamespace : "snapshotnamespace" ,
69
+ snapName : "snapshotname" ,
70
+ expectRef : nil ,
71
+ expectErr : true ,
76
72
},
77
73
}
78
74
79
75
for k , tc := range testcases {
80
76
t .Run (k , func (t * testing.T ) {
81
- ref , err := GetSnapshotSecretReference (tc .secretParams , tc .params , tc .snapContentName , tc .snapshot )
77
+ ref , err := GetSnapshotSecretReference (tc .secretParams , tc .params , tc .snapContentName , tc .snapNamespace , tc . snapName )
82
78
if err != nil {
83
79
if tc .expectErr {
84
80
return
0 commit comments