From 2f232fe92b1bf647afffbfdad2d128e36491a309 Mon Sep 17 00:00:00 2001 From: "kacaii.dev" Date: Fri, 11 Sep 2026 09:10:13 -0300 Subject: [PATCH] test/startup: add test for "ensure_exists" --- test/server/startup_test.gleam | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/server/startup_test.gleam b/test/server/startup_test.gleam index f38c1d9..9c57a3e 100644 --- a/test/server/startup_test.gleam +++ b/test/server/startup_test.gleam @@ -256,3 +256,25 @@ pub fn get_startup_members_test() -> Nil { Nil } + +pub fn ensure_exists_test() -> Nil { + use context <- server_test.with_context() + + // We are passing a random value. + let want = uuid.v7() + + // The query should early return to avoid interacting with a Startup + // that does not exist. + let assert Error(startup.NotFound(got)) = { + use <- startup.ensure_exists(context.database, want) + + Ok(Nil) + // ^^^ Depite the callback function ending with an Ok(_), this function + // should always return an Error(_) since the Startup does not exist. + } + + // The error should include the given ID in his payload + assert got == want as "return missing startup id" + + Nil +} -- 2.51.2