From efbe116f022a68f9b7c1b3cbe8d35ce1cce736de Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 16 Jul 2024 15:58:18 +1000 Subject: [PATCH] add simple unit test --- backend/controller/dal/async_calls_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 backend/controller/dal/async_calls_test.go diff --git a/backend/controller/dal/async_calls_test.go b/backend/controller/dal/async_calls_test.go new file mode 100644 index 0000000000..d0a08562df --- /dev/null +++ b/backend/controller/dal/async_calls_test.go @@ -0,0 +1,22 @@ +package dal + +import ( + "context" + "testing" + + "github.com/TBD54566975/ftl/backend/controller/sql/sqltest" + dalerrs "github.com/TBD54566975/ftl/backend/dal" + "github.com/TBD54566975/ftl/internal/log" + "github.com/alecthomas/assert/v2" +) + +func TestNoCallToAcquire(t *testing.T) { + ctx := log.ContextWithNewDefaultLogger(context.Background()) + conn := sqltest.OpenForTesting(ctx, t) + dal, err := New(ctx, conn) + assert.NoError(t, err) + + _, err = dal.AcquireAsyncCall(ctx) + assert.IsError(t, err, dalerrs.ErrNotFound) + assert.EqualError(t, err, "no pending async calls: not found") +}