@@ -30,6 +30,7 @@ type slugBuildCase struct {
3030 tarKey string
3131 putKey string
3232 cacheKey string
33+ gitShortHash string
3334 buildPack string
3435 slugBuilderImage string
3536 slugBuilderImagePullPolicy api.PullPolicy
@@ -42,6 +43,7 @@ type dockerBuildCase struct {
4243 namespace string
4344 env map [string ]interface {}
4445 tarKey string
46+ gitShortHash string
4547 imgName string
4648 dockerBuilderImage string
4749 dockerBuilderImagePullPolicy api.PullPolicy
@@ -57,13 +59,13 @@ func TestBuildPod(t *testing.T) {
5759 var pod * api.Pod
5860
5961 slugBuilds := []slugBuildCase {
60- {true , "test" , "default" , emptyEnv , "tar" , "put-url" , "cache-url" , "" , "" , api .PullAlways , "" },
61- {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "" , "" , api .PullAlways , "" },
62- {true , "test" , "default" , emptyEnv , "tar" , "put-url" , "cache-url" , "buildpack" , "" , api .PullAlways , "" },
63- {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "buildpack" , "" , api .PullAlways , "" },
64- {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "buildpack" , "customimage" , api .PullAlways , "" },
65- {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "buildpack" , "customimage" , api .PullIfNotPresent , "" },
66- {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "buildpack" , "customimage" , api .PullNever , "" },
62+ {true , "test" , "default" , emptyEnv , "tar" , "put-url" , "cache-url" , "deadbeef" , " " , "" , api .PullAlways , "" },
63+ {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "deadbeef" , " " , "" , api .PullAlways , "" },
64+ {true , "test" , "default" , emptyEnv , "tar" , "put-url" , "cache-url" , "deadbeef" , " buildpack" , "" , api .PullAlways , "" },
65+ {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "deadbeef" , " buildpack" , "" , api .PullAlways , "" },
66+ {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "deadbeef" , " buildpack" , "customimage" , api .PullAlways , "" },
67+ {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "deadbeef" , " buildpack" , "customimage" , api .PullIfNotPresent , "" },
68+ {true , "test" , "default" , env , "tar" , "put-url" , "cache-url" , "deadbeef" , " buildpack" , "customimage" , api .PullNever , "" },
6769 }
6870
6971 for _ , build := range slugBuilds {
@@ -75,6 +77,7 @@ func TestBuildPod(t *testing.T) {
7577 build .tarKey ,
7678 build .putKey ,
7779 build .cacheKey ,
80+ build .gitShortHash ,
7881 build .buildPack ,
7982 build .storageType ,
8083 build .slugBuilderImage ,
@@ -89,6 +92,7 @@ func TestBuildPod(t *testing.T) {
8992 t .Errorf ("expected %v but returned %v " , build .namespace , pod .ObjectMeta .Namespace )
9093 }
9194
95+ checkForEnv (t , pod , "SOURCE_VERSION" , build .gitShortHash )
9296 checkForEnv (t , pod , "TAR_PATH" , build .tarKey )
9397 checkForEnv (t , pod , "PUT_PATH" , build .putKey )
9498 checkForEnv (t , pod , "CACHE_PATH" , build .cacheKey )
@@ -110,13 +114,13 @@ func TestBuildPod(t *testing.T) {
110114 }
111115
112116 dockerBuilds := []dockerBuildCase {
113- {true , "test" , "default" , emptyEnv , "tar" , "" , "" , api .PullAlways , "" },
114- {true , "test" , "default" , env , "tar" , "" , "" , api .PullAlways , "" },
115- {true , "test" , "default" , emptyEnv , "tar" , "img" , "" , api .PullAlways , "" },
116- {true , "test" , "default" , env , "tar" , "img" , "" , api .PullAlways , "" },
117- {true , "test" , "default" , env , "tar" , "img" , "customimage" , api .PullAlways , "" },
118- {true , "test" , "default" , env , "tar" , "img" , "customimage" , api .PullIfNotPresent , "" },
119- {true , "test" , "default" , env , "tar" , "img" , "customimage" , api .PullNever , "" },
117+ {true , "test" , "default" , emptyEnv , "tar" , "deadbeef" , " " , "" , api .PullAlways , "" },
118+ {true , "test" , "default" , env , "tar" , "deadbeef" , " " , "" , api .PullAlways , "" },
119+ {true , "test" , "default" , emptyEnv , "tar" , "deadbeef" , " img" , "" , api .PullAlways , "" },
120+ {true , "test" , "default" , env , "tar" , "deadbeef" , " img" , "" , api .PullAlways , "" },
121+ {true , "test" , "default" , env , "tar" , "deadbeef" , " img" , "customimage" , api .PullAlways , "" },
122+ {true , "test" , "default" , env , "tar" , "deadbeef" , " img" , "customimage" , api .PullIfNotPresent , "" },
123+ {true , "test" , "default" , env , "tar" , "deadbeef" , " img" , "customimage" , api .PullNever , "" },
120124 }
121125 regEnv := map [string ]string {"REG_LOC" : "on-cluster" }
122126 for _ , build := range dockerBuilds {
@@ -126,6 +130,7 @@ func TestBuildPod(t *testing.T) {
126130 build .namespace ,
127131 build .env ,
128132 build .tarKey ,
133+ build .gitShortHash ,
129134 build .imgName ,
130135 build .storageType ,
131136 build .dockerBuilderImage ,
@@ -142,6 +147,7 @@ func TestBuildPod(t *testing.T) {
142147 t .Errorf ("expected %v but returned %v " , build .namespace , pod .ObjectMeta .Namespace )
143148 }
144149
150+ checkForEnv (t , pod , "SOURCE_VERSION" , build .gitShortHash )
145151 checkForEnv (t , pod , "TAR_PATH" , build .tarKey )
146152 checkForEnv (t , pod , "IMG_NAME" , build .imgName )
147153 checkForEnv (t , pod , "REG_LOC" , "on-cluster" )
0 commit comments