@@ -743,6 +743,65 @@ func TestGetStorageAccount(t *testing.T) {
743
743
}
744
744
}
745
745
746
+ //needs editing, could only get past first error for testing, could not get a fake environment running
747
+ func TestGetContainerReference (t * testing.T ) {
748
+ fakeAccountName := "storageaccountname"
749
+ fakeAccountKey := "test-key"
750
+ fakeContainerName := "test-con"
751
+ testCases := []struct {
752
+ name string
753
+ containerName string
754
+ secrets map [string ]string
755
+ expectedError error
756
+ }{
757
+ {
758
+ name : "failed to retrieve accountName" ,
759
+ containerName : fakeContainerName ,
760
+ secrets : map [string ]string {
761
+ "accountKey" : fakeAccountKey ,
762
+ },
763
+ expectedError : fmt .Errorf ("could not find %s or %s field secrets(%v)" , accountNameField , defaultSecretAccountName , map [string ]string {
764
+ "accountKey" : fakeAccountKey ,
765
+ }),
766
+ },
767
+ {
768
+ name : "failed to retrieve accountKey" ,
769
+ containerName : fakeContainerName ,
770
+ secrets : map [string ]string {
771
+ "accountName" : fakeAccountName ,
772
+ },
773
+ expectedError : fmt .Errorf ("could not find %s or %s field in secrets(%v)" , accountKeyField , defaultSecretAccountKey , map [string ]string {
774
+ "accountName" : fakeAccountName ,
775
+ }),
776
+ },
777
+ /*{
778
+ name: "container reference is nil",
779
+ containerName: fakeContainerName,
780
+ secrets: map[string]string{
781
+ "accountName": fakeAccountName,
782
+ "accountKey": fakeAccountKey,
783
+ },
784
+ expectedError: fmt.Errorf("ContainerReference of %s is nil", fakeContainerName),
785
+ },*/
786
+ }
787
+
788
+ d := NewFakeDriver ()
789
+ d .cloud = & azure.Cloud {}
790
+ d .cloud .KubeClient = fake .NewSimpleClientset ()
791
+ //d.cloud.Environment.StorageEndpointSuffix =
792
+ for _ , tc := range testCases {
793
+ t .Run (tc .name , func (t * testing.T ) {
794
+ container , err := getContainerReference (tc .containerName , tc .secrets , d .cloud .Environment )
795
+ if tc .expectedError != nil {
796
+ assert .Error (t , err )
797
+ assert .Equal (t , tc .expectedError , err )
798
+ } else {
799
+ container .Name = ""
800
+ }
801
+ })
802
+ }
803
+ }
804
+
746
805
func TestSetAzureCredentials (t * testing.T ) {
747
806
fakeClient := fake .NewSimpleClientset ()
748
807
0 commit comments