@@ -56,13 +56,23 @@ func TestConvertScripts(t *testing.T) {
5656 }}
5757
5858 gotInit , got := convertScripts (images .ShellImage , []v1alpha1.Step {{
59- Script : "script-1" ,
59+ Script : `#!/bin/sh
60+ script-1` ,
6061 Container : corev1.Container {Image : "step-1" },
6162 }, {
6263 // No script to convert here.
6364 Container : corev1.Container {Image : "step-2" },
6465 }, {
65- Script : "script-3" ,
66+ Script : `
67+ #!/bin/sh
68+ script-3` ,
69+ Container : corev1.Container {
70+ Image : "step-3" ,
71+ VolumeMounts : preExistingVolumeMounts ,
72+ Args : []string {"my" , "args" },
73+ },
74+ }, {
75+ Script : `no-shebang` ,
6676 Container : corev1.Container {
6777 Image : "step-3" ,
6878 VolumeMounts : preExistingVolumeMounts ,
@@ -77,13 +87,22 @@ func TestConvertScripts(t *testing.T) {
7787 Args : []string {"-c" , `tmpfile="/tekton/scripts/script-0-mz4c7"
7888touch ${tmpfile} && chmod +x ${tmpfile}
7989cat > ${tmpfile} << 'script-heredoc-randomly-generated-mssqb'
90+ #!/bin/sh
8091script-1
8192script-heredoc-randomly-generated-mssqb
8293tmpfile="/tekton/scripts/script-2-78c5n"
8394touch ${tmpfile} && chmod +x ${tmpfile}
8495cat > ${tmpfile} << 'script-heredoc-randomly-generated-6nl7g'
96+
97+ #!/bin/sh
8598script-3
8699script-heredoc-randomly-generated-6nl7g
100+ tmpfile="/tekton/scripts/script-3-j2tds"
101+ touch ${tmpfile} && chmod +x ${tmpfile}
102+ cat > ${tmpfile} << 'script-heredoc-randomly-generated-vr6ds'
103+ #!/bin/sh
104+ no-shebang
105+ script-heredoc-randomly-generated-vr6ds
87106` },
88107 VolumeMounts : []corev1.VolumeMount {scriptsVolumeMount },
89108 }
@@ -98,6 +117,15 @@ script-heredoc-randomly-generated-6nl7g
98117 Command : []string {"/tekton/scripts/script-2-78c5n" },
99118 Args : []string {"my" , "args" },
100119 VolumeMounts : append (preExistingVolumeMounts , scriptsVolumeMount ),
120+ }, {
121+ Image : "step-3" ,
122+ Command : []string {"/tekton/scripts/script-3-j2tds" },
123+ Args : []string {"my" , "args" },
124+ VolumeMounts : []corev1.VolumeMount {
125+ {Name : "pre-existing-volume-mount" , MountPath : "/mount/path" },
126+ {Name : "another-one" , MountPath : "/another/one" },
127+ {Name : "scripts" , MountPath : "/tekton/scripts" },
128+ },
101129 }}
102130 if d := cmp .Diff (wantInit , gotInit ); d != "" {
103131 t .Errorf ("Init Container Diff (-want, +got): %s" , d )
0 commit comments