### ----------------------------------------------------
### -- Ecosystem::Archive::Update
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;
use Ecosystem::Archive::Update;

plan 13;

my $shelves := $*PROGRAM.sibling("archive");
my $jsons   := $*PROGRAM.sibling("meta");

ok $shelves.e, "do we have an archive to test with";
ok $jsons.e,   "do we have a meta to test with";

my $ea = Ecosystem::Archive::Update.new(:$shelves, :$jsons);
isa-ok $ea, Ecosystem::Archive::Update;
is $ea.shelves, $shelves, 'did we get the right archive dir';
is $ea.jsons,   $jsons,   'did we get the right meta dir';

is $ea.identities.elems, 12, 'did we get right number of identities';

is-deeply $ea.identities.keys.grep(!*.starts-with("CORE:" | "rakudo")).sort, <
  P5study:ver<0.0.3>:auth<cpan:ELIZABETH>
  P5study:ver<0.0.4>:auth<cpan:ELIZABETH>
  P5study:ver<0.0.5>:auth<cpan:ELIZABETH>
  P5study:ver<0.0.6>:auth<zef:lizmat>
  eigenstates:ver<0.0.1>:auth<cpan:ELIZABETH>
  eigenstates:ver<0.0.2>:auth<cpan:ELIZABETH>
  eigenstates:ver<0.0.3>:auth<cpan:ELIZABETH>
  eigenstates:ver<0.0.4>:auth<cpan:ELIZABETH>
  eigenstates:ver<0.0.5>:auth<fez:lizmat>
  eigenstates:ver<0.0.6>:auth<zef:lizmat>
  eigenstates:ver<0.0.7>:auth<zef:lizmat>
>, 'did we get the right identities';

$ea.note: "foo";
is $ea.notes.elems, 1, 'did the first note get added';
$ea.note: "bar";
is $ea.notes.elems, 2, 'did the second note get added';
$ea.note: "baz";
is $ea.notes.elems, 3, 'did the third note get added';
is-deeply $ea.notes, <foo bar baz>, 'did we get all the notes';
is-deeply $ea.clear-notes, <foo bar baz>, 'did we get all the notes cleared';
is $ea.notes.elems, 0, 'were all notes really cleared';

# vim: expandtab shiftwidth=4


