File Coverage: t/bin-yukki-git-init.t

# File Coverage

File: | t/bin-yukki-git-init.t
Coverage: | 97.5%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 |  |  |  |  |  |  | #!/usr/bin/env perl
2 | 1 1 |  |  | 1 |  | 1816 3 | use 5.12.1;
3 |
4 | 1 1 1 |  |  | 1 |  | 378 4959 36 | use Path::Tiny qw( tempdir );
5 | 1 1 1 |  |  | 1 |  | 3051 23887 3 | use Git::Repository;
6 | 1 1 1 |  |  | 1 |  | 182 64696 4 | use Test2::V0;
7 | 1 1 1 |  |  | 1 |  | 1452 10112 4 | use Test::Script;
8 |
9 | 1 |  |  |  |  | 47337 | plan 12;
10 |
11 | 1 |  |  |  |  | 2410 | script_compiles('bin/yukki-setup', 'yukki-setup compiles');
12 | 1 |  |  |  |  | 335271 | script_compiles('bin/yukki-git-init', 'yukki-git-init compiles');
13 |
14 | 1 |  |  |  |  | 250491 | my $tempdir = tempdir;
15 | 1 | 50 |  |  |  | 692 | diag("TEMPDIR = $tempdir") if $ENV{YUKKI_TEST_KEEP_FILES};
16 |
17 | 1 |  |  |  |  | 7 | script_runs([ 'bin/yukki-setup', "$tempdir/yukki-test", 'skel' ],
18 |  |  |  |  |  |  | 'yukki-setup runs');
19 |
20 | 1 |  |  |  |  | 403029 | ok(-d "$tempdir/yukki-test", 'created the test directory');
21 | 1 |  |  |  |  | 196 | ok(!-f "$tempdir/yukki-test/var/db/users/foo",
22 |  |  |  |  |  |  | 'the user we are about to create does not exist yet');
23 |
24 | 1 |  |  |  |  | 283 | $ENV{YUKKI_CONFIG} = "$tempdir/yukki-test/etc/yukki.conf";
25 | 1 |  |  |  |  | 25 | script_runs([ 'bin/yukki-git-init', 'main' ], 'yukki-git-init main ran');
26 |
27 | 1 |  |  |  |  | 573041 | ok(-d "$tempdir/yukki-test/repositories", 'created the repositories directory');
28 | 1 |  |  |  |  | 197 | ok(-d "$tempdir/yukki-test/repositories/main.git", 'created the main.git repository');
29 |
30 | 1 |  |  |  |  | 218 | my $git = Git::Repository->new( git_dir => "$tempdir/yukki-test/repositories/main.git" );
31 | 1 |  |  |  |  | 41944 | my $list = $git->run('ls-tree', 'refs/heads/master');
32 |
33 | 1 |  |  |  |  | 9932 | like($list, qr/\bhome\.yukki\b/, 'created home.yukki');
34 |
35 | 1 |  |  |  |  | 488 | my $first_comment = $git->run('show', 'refs/heads/master');
36 | 1 |  |  |  |  | 16482 | like($first_comment, qr/Initializing/, 'expected comment');
37 | 1 |  |  |  |  | 460 | like($first_comment, qr{diff --git a/home.yukki b/home.yukki}, 'contains the expected file');
38 | 1 |  |  |  |  | 262 | like($first_comment, qr{\+\# Main}, 'the file has expected heading');