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 +}