Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[t/subcommands/fetch.t] fleshed out

24 tests now run and fail.
  • Loading branch information...
commit 61dc53918176998b25234ecc89af28d736ac46a6 1 parent d112366
Carl Mäsak authored June 12, 2010
26  lib/App/Pls.pm
... ...
@@ -0,0 +1,26 @@
  1
+use v6;
  2
+
  3
+enum State <gone fetched>;
  4
+enum Result <success failure>;
  5
+
  6
+role App::Pls::ProjectsState {
  7
+}
  8
+
  9
+class App::Pls::ProjectsState::Hash does App::Pls::ProjectsState {
  10
+}
  11
+
  12
+role App::Pls::Fetcher {
  13
+}
  14
+
  15
+class App::Pls::Core {
  16
+    has App::Pls::ProjectsState $!projects;
  17
+    has App::Pls::Fetcher       $!fetcher;
  18
+
  19
+    method state-of($project) {
  20
+        return -1;
  21
+    }
  22
+
  23
+    method fetch(*@projects) {
  24
+        return;
  25
+    }
  26
+}
63  t/subcommands/fetch.t
... ...
@@ -1,14 +1,65 @@
1 1
 use v6;
2 2
 use Test;
3 3
 
4  
-# [T] Fetch a project: Succeed.
  4
+use App::Pls;
5 5
 
6  
-# [T] Fetch a project; an unexpected error occurs: Fail.
  6
+my %projects =
  7
+    will-succeed => {},
  8
+    will-fail    => {},
  9
+    # RAKUDO: Need quotes around keys starting with 'has-' [perl #75694]
  10
+    'has-deps'   => { :deps<A B> },
  11
+    A            => {},
  12
+    B            => { :deps<C D> },
  13
+    C            => {},
  14
+    D            => {},
  15
+    circ-deps    => { :deps<E> },
  16
+    E            => { :deps<circ-deps> },
  17
+    dirdep-fails => { :deps<will-fail> },
  18
+    indir-fails  => { :deps<dirdep-fails> },
  19
+;
7 20
 
8  
-# [T] Fetch a project with dependencies: Fetch dependencies too.
  21
+class Mock::Fetcher does App::Pls::Fetcher {
  22
+}
9 23
 
10  
-# [T] Fetch a project with circular dependencies: Fail.
  24
+my $core = App::Pls::Core.new(
  25
+    :projects(App::Pls::ProjectsState::Hash.new(%projects)),
  26
+    :fetcher(Mock::Fetcher.new()),
  27
+);
11 28
 
12  
-# [T] Fetch a project whose direct dependency fails: Fail.
  29
+plan 24;
13 30
 
14  
-# [T] Fetch a project whose indirect dependency fails: Fail.
  31
+given $core {
  32
+    # [T] Fetch a project: Succeed.
  33
+    is .state-of(<will-succeed>), gone, "State is now 'gone'";
  34
+    is .fetch(<will-succeed>), success, "Fetch a project: Succeed";
  35
+    is .state-of(<will-succeed>), fetched, "State after: 'fetched'";
  36
+
  37
+    # [T] Fetch a project; an unexpected error occurs: Fail.
  38
+    is .fetch(<will-fail>), failure, "Fetch a project: Fail";
  39
+    is .state-of(<will-fail>), gone, "State after: 'gone'";
  40
+
  41
+    # [T] Fetch a project with dependencies: Fetch dependencies too.
  42
+    for <A B C D> -> $dep {
  43
+        is .state-of($dep), gone, "State before of $dep: 'gone'";
  44
+    }
  45
+    is .fetch(<has-deps>), success, "Fetch project's dependencies, too";
  46
+    for <A B C D> -> $dep {
  47
+        is .state-of($dep), fetched, "State after of $dep: 'fetched'";
  48
+    }
  49
+
  50
+    # [T] Fetch a project with circular dependencies: Fail.
  51
+    is .fetch(<circ-deps>), failure, "Fetch a project with circ deps: fail";
  52
+    is .state-of(<circ-deps>), gone, "State after of circ-deps: 'gone'";
  53
+    is .state-of(<E>), gone, "State after of E: 'gone'";
  54
+
  55
+    # [T] Fetch a project whose direct dependency fails: Fail.
  56
+    is .fetch(<dirdep-fails>), failure, "Fail on direct dependency failure";
  57
+    is .state-of(<dirdep-fails>), gone, "State after of dirdep-fails: 'gone'";
  58
+    is .state-of(<will-fail>), gone, "State after of will-fail: 'gone'";
  59
+
  60
+    # [T] Fetch a project whose indirect dependency fails: Fail.
  61
+    is .fetch(<indir-fails>), failure, "Fail on indirect dependency failure";
  62
+    is .state-of(<indir-fails>), gone, "State after of indir-fails: 'gone'";
  63
+    is .state-of(<dirdep-fails>), gone, "State after of dirdep-fails: 'gone'";
  64
+    is .state-of(<will-fail>), gone, "State after of will-fail: 'gone'";
  65
+}

0 notes on commit 61dc539

Please sign in to comment.
Something went wrong with that request. Please try again.