Skip to content

Commit

Permalink
fix: convert to absolute path immediately incase test changes dirs (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
matt2e authored May 7, 2024
1 parent 26401ca commit e31e64d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go-runtime/ftl/ftltest/ftltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"

"github.com/TBD54566975/ftl/backend/schema"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit e31e64d

Please sign in to comment.