@@ -3,11 +3,12 @@ package engine_test
33import (
44 "context"
55 "fmt"
6+ "path"
7+ "path/filepath"
68 "slices"
79 "testing"
810 "time"
911
10- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
1112 "github.com/stretchr/testify/require"
1213 "go.uber.org/mock/gomock"
1314
@@ -64,6 +65,9 @@ func TestExecutor_Execute(t *testing.T) {
6465 instanceID , err := uuid .Parse ("37087cc2-e4ba-4fe0-8230-cda372778ed7" )
6566 require .NoError (t , err )
6667
68+ absPath , err := filepath .Abs ("." )
69+ require .NoError (t , err )
70+
6771 var (
6872 ctx , cancel = context .WithTimeout (context .Background (), time .Second )
6973 ctrl = gomock .NewController (t )
@@ -220,16 +224,10 @@ func TestExecutor_Execute(t *testing.T) {
220224 require .NoError (t , err )
221225 require .NotNil (t , exe )
222226
223- var (
224- envVars = []string {
225- fmt .Sprintf ("SMITHY_INSTANCE_ID=%s" , instanceID .String ()),
226- "SMITHY_LOG_LEVEL=debug" ,
227- }
228- platform = & ocispec.Platform {
229- Architecture : "amd64" ,
230- OS : "linux" ,
231- }
232- )
227+ var envVars = []string {
228+ fmt .Sprintf ("SMITHY_INSTANCE_ID=%s" , instanceID .String ()),
229+ "SMITHY_LOG_LEVEL=debug" ,
230+ }
233231
234232 t .Run ("it executes a workflow correctly" , func (t * testing.T ) {
235233 gomock .InOrder (
@@ -243,10 +241,10 @@ func TestExecutor_Execute(t *testing.T) {
243241 Executable : "/bin/clone" ,
244242 EnvVars : appendAndSort (envVars , "REPO_URL=github.com/andream16/tree" ),
245243 VolumeBindings : []string {
244+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
246245 sourceCodeHostPath + ":" + sourceCodeMountPath ,
247246 },
248- Cmd : []string {"/workspace/source-code" },
249- Platform : platform ,
247+ Cmd : []string {"/workspace/source-code" },
250248 },
251249 ).
252250 Return (nil ),
@@ -261,11 +259,11 @@ func TestExecutor_Execute(t *testing.T) {
261259 Executable : "/bin/prescan" ,
262260 EnvVars : envVars ,
263261 VolumeBindings : []string {
262+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
264263 scratchHostPath + ":" + scratchMountPath ,
265264 sourceCodeHostPath + ":" + sourceCodeMountPath ,
266265 },
267- Cmd : []string {"--from=/workspace/source-code" , "--to=/workspace/scratch" },
268- Platform : platform ,
266+ Cmd : []string {"--from=/workspace/source-code" , "--to=/workspace/scratch" },
269267 },
270268 ).
271269 Return (nil ),
@@ -280,10 +278,10 @@ func TestExecutor_Execute(t *testing.T) {
280278 Executable : "/bin/scan" ,
281279 EnvVars : envVars ,
282280 VolumeBindings : []string {
281+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
283282 scratchHostPath + ":" + scratchMountPath ,
284283 },
285- Cmd : []string {"/workspace/scratch" },
286- Platform : platform ,
284+ Cmd : []string {"/workspace/scratch" },
287285 },
288286 ).
289287 Return (nil ),
@@ -298,10 +296,10 @@ func TestExecutor_Execute(t *testing.T) {
298296 Executable : "/bin/scan" ,
299297 EnvVars : appendAndSort (envVars , "FROM=/workspace/source-code" , "TO=/workspace/scratch" ),
300298 VolumeBindings : []string {
299+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
301300 scratchHostPath + ":" + scratchMountPath ,
302301 sourceCodeHostPath + ":" + sourceCodeMountPath ,
303302 },
304- Platform : platform ,
305303 },
306304 ).
307305 Return (nil ),
@@ -311,12 +309,13 @@ func TestExecutor_Execute(t *testing.T) {
311309 RunAndWait (
312310 ctx ,
313311 engine.ContainerConfig {
314- Name : enricherComponentStepName ,
315- Image : enricherComponentImage ,
316- Executable : "/bin/enrich" ,
317- VolumeBindings : []string {},
318- EnvVars : envVars ,
319- Platform : platform ,
312+ Name : enricherComponentStepName ,
313+ Image : enricherComponentImage ,
314+ Executable : "/bin/enrich" ,
315+ VolumeBindings : []string {
316+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
317+ },
318+ EnvVars : envVars ,
320319 },
321320 ).
322321 Return (nil ),
@@ -326,12 +325,13 @@ func TestExecutor_Execute(t *testing.T) {
326325 RunAndWait (
327326 ctx ,
328327 engine.ContainerConfig {
329- Name : filterComponentStepName ,
330- Image : filterComponentImage ,
331- Executable : "/bin/filter" ,
332- VolumeBindings : []string {},
333- EnvVars : envVars ,
334- Platform : platform ,
328+ Name : filterComponentStepName ,
329+ Image : filterComponentImage ,
330+ Executable : "/bin/filter" ,
331+ VolumeBindings : []string {
332+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
333+ },
334+ EnvVars : envVars ,
335335 },
336336 ).
337337 Return (nil ),
@@ -341,15 +341,16 @@ func TestExecutor_Execute(t *testing.T) {
341341 RunAndWait (
342342 ctx ,
343343 engine.ContainerConfig {
344- Name : reporterComponentStepName ,
345- Image : reporterComponentImage ,
346- Executable : "/bin/report" ,
347- VolumeBindings : []string {},
344+ Name : reporterComponentStepName ,
345+ Image : reporterComponentImage ,
346+ Executable : "/bin/report" ,
347+ VolumeBindings : []string {
348+ path .Join (absPath , fmt .Sprintf ("%s:/workspace" , ".smithy" )),
349+ },
348350 Cmd : []string {
349351 "-arg1=1" ,
350352 },
351- EnvVars : envVars ,
352- Platform : platform ,
353+ EnvVars : envVars ,
353354 },
354355 ).
355356 Return (nil ),
0 commit comments