Skip to content

Commit

Permalink
fix: ftltest context option order insensivity (#2018)
Browse files Browse the repository at this point in the history
fixes #1866 

introduces a rudimentary partial ordering scheme for context options -
this is used to sort them before they get executed to build the context
  • Loading branch information
jonathanj-square authored Jul 10, 2024
1 parent 7469ad4 commit 7354e2d
Show file tree
Hide file tree
Showing 2 changed files with 197 additions and 132 deletions.
13 changes: 13 additions & 0 deletions backend/controller/sql/testdata/go/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ func TestDatabase(t *testing.T) {
assert.Equal(t, "unit test 2", list[0])
}

func TestOptionOrdering(t *testing.T) {
ctx := ftltest.Context(
ftltest.WithDatabase(db), // <--- consumes DSNs
ftltest.WithProjectFile("ftl-project.toml"), // <--- provides DSNs
)

Insert(ctx, InsertRequest{Data: "unit test 1"})
list, err := getAll(ctx)
assert.NoError(t, err)
assert.Equal(t, 1, len(list))
assert.Equal(t, "unit test 1", list[0])
}

func getAll(ctx context.Context) ([]string, error) {
rows, err := db.Get(ctx).Query("SELECT data FROM requests ORDER BY created_at;")
if err != nil {
Expand Down
Loading

0 comments on commit 7354e2d

Please sign in to comment.