@@ -112,9 +112,6 @@ def test_set_entrypoint(self):
112
112
self .assertRegexpMatches (dockerfile , regex )
113
113
114
114
def test_volumes (self ):
115
- """
116
- Test that cmd: is mapped into a CMD instruction
117
- """
118
115
with open (self .yaml , 'ab' ) as f :
119
116
f .write ("volumes:\n - '/var/lib'\n - '/usr/lib'" .encode ())
120
117
@@ -128,3 +125,35 @@ def test_volumes(self):
128
125
dockerfile = f .read ()
129
126
regex = re .compile (r'.*VOLUME \["/var/lib"\]\nVOLUME \["/usr/lib"\]' , re .MULTILINE )
130
127
self .assertRegexpMatches (dockerfile , regex )
128
+
129
+ def test_default_substitution (self ):
130
+ with open (self .yaml , 'ab' ) as f :
131
+ f .write ("from: {{FROM:rhel:7}}\n version: 1.0" .encode ())
132
+
133
+ generator = Generator (self .log , self .args )
134
+ generator .configure ()
135
+ generator .render_from_template ()
136
+
137
+ self .assertEqual (generator .cfg ['from' ], 'rhel:7' )
138
+
139
+ with open (os .path .join (self .target , "Dockerfile" ), "r" ) as f :
140
+ dockerfile = f .read ()
141
+ regex = re .compile (r'.*FROM rhel:7' , re .MULTILINE )
142
+ self .assertRegexpMatches (dockerfile , regex )
143
+
144
+ def test_substitution_with_parameters (self ):
145
+ with open (self .yaml , 'ab' ) as f :
146
+ f .write ("from: {{FROM:rhel:7}}\n version: 1.0" .encode ())
147
+
148
+ self .args .params = {'FROM' : 'centos:7' }
149
+
150
+ generator = Generator (self .log , self .args )
151
+ generator .configure ()
152
+ generator .render_from_template ()
153
+
154
+ self .assertEqual (generator .cfg ['from' ], 'centos:7' )
155
+
156
+ with open (os .path .join (self .target , "Dockerfile" ), "r" ) as f :
157
+ dockerfile = f .read ()
158
+ regex = re .compile (r'.*FROM centos:7' , re .MULTILINE )
159
+ self .assertRegexpMatches (dockerfile , regex )
0 commit comments