NAME
DBIO::Test::Future - Synchronous mock Future for DBIO test suite
VERSION
version 0.900000
SYNOPSIS
use DBIO::Test::Future;
my $f = DBIO::Test::Future->done('hello', 'world');
ok $f->is_ready;
is_deeply [$f->get], ['hello', 'world'];
my $f2 = $f->then(sub { return uc $_[0] });
is_deeply [$f2->get], ['HELLO'];
my $err = DBIO::Test::Future->fail('something broke');
ok $err->is_failed;
DESCRIPTION
A minimal synchronous Future implementation for testing DBIO's async interface without requiring any event loop framework.
Just like DBIO::Test::Storage provides a fake storage for testing SQL generation without a real database, DBIO::Test::Future provides a fake Future that resolves immediately for testing async method signatures.
All methods execute synchronously -- then chains run immediately, get returns instantly, and is_ready is always true.
METHODS
done
my $f = DBIO::Test::Future->done(@values);
Create an immediately-resolved successful Future.
fail
my $f = DBIO::Test::Future->fail($error);
Create an immediately-resolved failed Future.
is_ready
Returns true (always, since test futures resolve immediately).
is_failed
Returns true if this Future was created with "fail".
get
Returns the resolved values. Dies if the Future failed.
then
my $f2 = $f->then(sub { my @result = @_; return @new_result });
Executes the callback immediately with the resolved values and returns a new Future with the callback's return value. If the callback dies, returns a failed Future. If this Future is failed, returns itself without calling the callback.
catch
my $f2 = $f->catch(sub { my $error = shift; ... });
Executes the callback immediately with the error if this Future failed. Returns itself unchanged if successful.
and_then
my $f2 = $f->and_then(sub { return DBIO::Test::Future->done(...) });
Like "then" but expects the callback to return a Future object. Flattens nested Futures.
needs_all
my $f = DBIO::Test::Future->needs_all(@futures);
Returns a Future that resolves when all input Futures have resolved. Fails if any input Future fails. Results are collected in order.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.