Skip to content

Commit

Permalink
[t/subcommands/fetch.t] fleshed out
Browse files Browse the repository at this point in the history
24 tests now run and fail.
  • Loading branch information
Carl Masak committed Jun 12, 2010
1 parent d112366 commit 61dc539
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 6 deletions.
26 changes: 26 additions & 0 deletions lib/App/Pls.pm
@@ -0,0 +1,26 @@
use v6;

enum State <gone fetched>;
enum Result <success failure>;

role App::Pls::ProjectsState {
}

class App::Pls::ProjectsState::Hash does App::Pls::ProjectsState {
}

role App::Pls::Fetcher {
}

class App::Pls::Core {
has App::Pls::ProjectsState $!projects;
has App::Pls::Fetcher $!fetcher;

method state-of($project) {
return -1;
}

method fetch(*@projects) {
return;
}
}
63 changes: 57 additions & 6 deletions t/subcommands/fetch.t
@@ -1,14 +1,65 @@
use v6;
use Test;

# [T] Fetch a project: Succeed.
use App::Pls;

# [T] Fetch a project; an unexpected error occurs: Fail.
my %projects =
will-succeed => {},
will-fail => {},
# RAKUDO: Need quotes around keys starting with 'has-' [perl #75694]
'has-deps' => { :deps<A B> },
A => {},
B => { :deps<C D> },
C => {},
D => {},
circ-deps => { :deps<E> },
E => { :deps<circ-deps> },
dirdep-fails => { :deps<will-fail> },
indir-fails => { :deps<dirdep-fails> },
;

# [T] Fetch a project with dependencies: Fetch dependencies too.
class Mock::Fetcher does App::Pls::Fetcher {
}

# [T] Fetch a project with circular dependencies: Fail.
my $core = App::Pls::Core.new(
:projects(App::Pls::ProjectsState::Hash.new(%projects)),
:fetcher(Mock::Fetcher.new()),
);

# [T] Fetch a project whose direct dependency fails: Fail.
plan 24;

# [T] Fetch a project whose indirect dependency fails: Fail.
given $core {
# [T] Fetch a project: Succeed.
is .state-of(<will-succeed>), gone, "State is now 'gone'";
is .fetch(<will-succeed>), success, "Fetch a project: Succeed";
is .state-of(<will-succeed>), fetched, "State after: 'fetched'";

# [T] Fetch a project; an unexpected error occurs: Fail.
is .fetch(<will-fail>), failure, "Fetch a project: Fail";
is .state-of(<will-fail>), gone, "State after: 'gone'";

# [T] Fetch a project with dependencies: Fetch dependencies too.
for <A B C D> -> $dep {
is .state-of($dep), gone, "State before of $dep: 'gone'";
}
is .fetch(<has-deps>), success, "Fetch project's dependencies, too";
for <A B C D> -> $dep {
is .state-of($dep), fetched, "State after of $dep: 'fetched'";
}

# [T] Fetch a project with circular dependencies: Fail.
is .fetch(<circ-deps>), failure, "Fetch a project with circ deps: fail";
is .state-of(<circ-deps>), gone, "State after of circ-deps: 'gone'";
is .state-of(<E>), gone, "State after of E: 'gone'";

# [T] Fetch a project whose direct dependency fails: Fail.
is .fetch(<dirdep-fails>), failure, "Fail on direct dependency failure";
is .state-of(<dirdep-fails>), gone, "State after of dirdep-fails: 'gone'";
is .state-of(<will-fail>), gone, "State after of will-fail: 'gone'";

# [T] Fetch a project whose indirect dependency fails: Fail.
is .fetch(<indir-fails>), failure, "Fail on indirect dependency failure";
is .state-of(<indir-fails>), gone, "State after of indir-fails: 'gone'";
is .state-of(<dirdep-fails>), gone, "State after of dirdep-fails: 'gone'";
is .state-of(<will-fail>), gone, "State after of will-fail: 'gone'";
}

0 comments on commit 61dc539

Please sign in to comment.