/
31-index-add-file.t
36 lines (21 loc) · 1000 Bytes
/
31-index-add-file.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use Test;
use File::Temp;
use LibGit2;
plan 14;
my $testdir = tempdir;
my $repo = Git::Repository.init($testdir);
is $repo.status-file('afile'), Nil, 'afile not present';
$testdir.IO.child('afile').spurt("This is some content for a file.\n");
isa-ok my $status = $repo.status-file('afile'), Git::Status::File, 'status-file';
is $status.is-workdir-new, True, 'is-workdir-new';
is $status.is-index-new, False, 'is-index-new';
isa-ok my $index = $repo.index, Git::Index, 'index';
lives-ok { $index.add-bypath('afile') }, 'add-bypath';
isa-ok $status = $repo.status-file('afile'), Git::Status::File, 'status-file';
is $status.is-workdir-new, False, 'is-workdir-new';
is $status.is-index-new, True, 'is-index-new';
lives-ok { $index.remove-bypath('afile') }, 'remove-bypath';
isa-ok $status = $repo.status-file('afile'), Git::Status::File, 'status-file';
is $status.is-workdir-new, True, 'is-workdir-new';
is $status.is-index-new, False, 'is-index-new';
lives-ok { $index.write }, 'write';