@@ -1902,7 +1902,7 @@ func TestAdditionalVolume(t *testing.T) {
19021902 Name : "test6" ,
19031903 MountPath : "/test6" ,
19041904 SubPath : "$(POD_NAME)" ,
1905- IsSubPathExpr : true ,
1905+ IsSubPathExpr : util . True () ,
19061906 TargetContainers : nil , // should mount only to postgres
19071907 VolumeSource : v1.VolumeSource {
19081908 EmptyDir : & v1.EmptyDirVolumeSource {},
@@ -1922,7 +1922,9 @@ func TestAdditionalVolume(t *testing.T) {
19221922 ResourceLimits : acidv1.ResourceDescription {CPU : k8sutil .StringToPointer ("1" ), Memory : k8sutil .StringToPointer ("10" )},
19231923 },
19241924 Volume : acidv1.Volume {
1925- Size : "1G" ,
1925+ Size : "1G" ,
1926+ SubPath : "$(POD_NAME)" ,
1927+ IsSubPathExpr : util .True (),
19261928 },
19271929 AdditionalVolumes : additionalVolumes ,
19281930 Sidecars : []acidv1.Sidecar {
@@ -1954,31 +1956,25 @@ func TestAdditionalVolume(t *testing.T) {
19541956 assert .NoError (t , err )
19551957
19561958 tests := []struct {
1957- subTest string
1958- container string
1959- expectedMounts []string
1960- expectedSubPath []string
1959+ subTest string
1960+ container string
1961+ expectedMounts []string
1962+ expectedSubPaths []string
1963+ expectedSubPathExprs []string
19611964 }{
19621965 {
1963- subTest : "checking volume mounts of postgres container" ,
1964- container : constants .PostgresContainerName ,
1965- expectedMounts : []string {"pgdata" , "test1" , "test3" , "test4" },
1966- },
1967- {
1968- subTest : "checking volume mounts of sidecar container" ,
1969- container : "sidecar" ,
1970- expectedMounts : []string {"pgdata" , "test1" , "test2" },
1966+ subTest : "checking volume mounts of postgres container" ,
1967+ container : constants .PostgresContainerName ,
1968+ expectedMounts : []string {"pgdata" , "test1" , "test3" , "test4" , "test5" , "test6" },
1969+ expectedSubPaths : []string {"" , "" , "" , "" , "subpath" , "" },
1970+ expectedSubPathExprs : []string {"$(POD_NAME)" , "" , "" , "" , "" , "$(POD_NAME)" },
19711971 },
19721972 {
1973- subTest : "checking volume mounts with subPath" ,
1974- container : constants .PostgresContainerName ,
1975- expectedMounts : []string {"test5" },
1976- expectedSubPath : []string {"subpath" },
1977- },
1978- {
1979- subTest : "checking volume mounts with subPathExpr" ,
1980- container : constants .PostgresContainerName ,
1981- expectedMounts : []string {"test6" },
1973+ subTest : "checking volume mounts of sidecar container" ,
1974+ container : "sidecar" ,
1975+ expectedMounts : []string {"pgdata" , "test1" , "test2" },
1976+ expectedSubPaths : []string {"" , "" , "" },
1977+ expectedSubPathExprs : []string {"$(POD_NAME)" , "" , "" },
19821978 },
19831979 }
19841980
@@ -1990,6 +1986,7 @@ func TestAdditionalVolume(t *testing.T) {
19901986 mounts := []string {}
19911987 subPaths := []string {}
19921988 subPathExprs := []string {}
1989+
19931990 for _ , volumeMounts := range container .VolumeMounts {
19941991 mounts = append (mounts , volumeMounts .Name )
19951992 subPaths = append (subPaths , volumeMounts .SubPath )
@@ -2001,14 +1998,14 @@ func TestAdditionalVolume(t *testing.T) {
20011998 t .Name (), tt .subTest , mounts , tt .expectedMounts )
20021999 }
20032000
2004- if ! util .IsEqualIgnoreOrder (subPaths , tt .expectedSubPath ) {
2001+ if ! util .IsEqualIgnoreOrder (subPaths , tt .expectedSubPaths ) {
20052002 t .Errorf ("%s %s: different volume subPaths: got %v, expected %v" ,
2006- t .Name (), tt .subTest , mounts , tt .expectedSubPath )
2003+ t .Name (), tt .subTest , subPaths , tt .expectedSubPaths )
20072004 }
20082005
2009- if ! util .IsEqualIgnoreOrder (subPathExprs , [] string { container . Name } ) {
2006+ if ! util .IsEqualIgnoreOrder (subPathExprs , tt . expectedSubPathExprs ) {
20102007 t .Errorf ("%s %s: different volume subPathExprs: got %v, expected %v" ,
2011- t .Name (), tt .subTest , mounts , tt .expectedMounts )
2008+ t .Name (), tt .subTest , subPathExprs , tt .expectedSubPathExprs )
20122009 }
20132010 }
20142011 }
0 commit comments