Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[t/subcommands/fetch.t] fleshed out

24 tests now run and fail.
  • Loading branch information...
commit 61dc53918176998b25234ecc89af28d736ac46a6 1 parent d112366
@masak authored
Showing with 83 additions and 6 deletions.
  1. +26 −0 lib/App/Pls.pm
  2. +57 −6 t/subcommands/fetch.t
View
26 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;
+ }
+}
View
63 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'";
+}
Please sign in to comment.
Something went wrong with that request. Please try again.