### ----------------------------------------------------
### -- Mi6::Helper
### -- Licenses: Artistic-2.0
### -- Authors: Tom Browder <tbrowder@acm.org>
### -- File: t/1-create.rakutest
### ----------------------------------------------------
use Test;

use File::Temp;
use File::Directory::Tree;

use Mi6::Helper;
use Mi6::Helper::Utils;

my $debug = 0;

my ($Xstr, $Xnam, $tdir, $o);

if $debug {
    $tdir = "/tmp/A";
    rmtree $tdir if $tdir.IO.d;
    mkdir $tdir;
}
else {
    $tdir = tempdir;
}

chdir $tdir;

my $module-name = 'Foo::Bar-Baz';
my $module-dir  = 'Foo-Bar-Baz';
my $descrip = 'Some text';
my $parent-dir = $tdir;
put-hidden-text($descrip, :$parent-dir, :$module-name);

$o = Mi6::Helper.new: :$parent-dir, :$module-name;
isa-ok $o, Mi6::Helper;
is $o.descrip, $descrip, "descrip: '$descrip'";
is $o.module-name, $module-name;
is $o.module-dir, $module-dir;

# do it again without hidden text

if $debug {
    $tdir = "/tmp/A";
    rmtree $tdir if $tdir.IO.d;
    mkdir $tdir;
}
else {
    $tdir = tempdir;
}
$parent-dir = $tdir;
chdir $tdir;

$descrip = 'blah blah blah'; # default from 'mi6'
$o = Mi6::Helper.new: :$parent-dir, :$module-name;
isa-ok $o, Mi6::Helper;
is $o.descrip, $descrip, "descrip: '$descrip'";
is $o.module-name, $module-name;
is $o.module-dir, $module-dir;

done-testing;


