From e31e64d259322b3256ef632ccdf6d7fffa19b494 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 7 May 2024 10:50:05 +1000 Subject: [PATCH] fix: convert to absolute path immediately incase test changes dirs (#1418) Catches an edge case where the working directory changes between when the relative path is passed in and when the inner function is executed --- go-runtime/ftl/ftltest/ftltest.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go-runtime/ftl/ftltest/ftltest.go b/go-runtime/ftl/ftltest/ftltest.go index b7a7040077..18d8e7aede 100644 --- a/go-runtime/ftl/ftltest/ftltest.go +++ b/go-runtime/ftl/ftltest/ftltest.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "os" + "path/filepath" "reflect" "github.com/TBD54566975/ftl/backend/schema" @@ -63,7 +64,12 @@ func Context(options ...Option) context.Context { // // ) func WithProjectFile(path string) Option { + // Convert to absolute path immediately in case working directory changes + path, err := filepath.Abs(path) return func(ctx context.Context, state *OptionsState) error { + if err != nil { + return err + } if _, err := os.Stat(path); err != nil { return fmt.Errorf("error accessing project file: %w", err) }