]> git.notmuchmail.org Git - notmuch/blob - test/T850-git.sh
test: initial tests for notmuch-git
[notmuch] / test / T850-git.sh
1 #!/usr/bin/env bash
2 test_description='"notmuch git" to save and restore tags'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
5 add_email_corpus
6
7 git config --global user.email notmuch@example.org
8 git config --global user.name  "Notmuch Test Suite"
9
10 test_begin_subtest "init"
11 test_expect_success "notmuch git -p '' -C remote.git init"
12
13 test_begin_subtest "clone"
14 test_expect_success "notmuch git -p '' -C tags.git clone remote.git"
15
16 test_begin_subtest "commit"
17 notmuch git -C tags.git -p '' commit
18 git -C tags.git ls-tree -r --name-only HEAD | xargs dirname | sort -u | sed s,tags/,id:, > OUTPUT
19 notmuch search --output=messages '*' | sort > EXPECTED
20 test_expect_equal_file_nonempty EXPECTED OUTPUT
21
22 test_begin_subtest "checkout"
23 notmuch dump > BEFORE
24 notmuch tag -inbox '*'
25 notmuch git -C tags.git -p '' checkout
26 notmuch dump > AFTER
27 test_expect_equal_file_nonempty BEFORE AFTER
28
29 test_begin_subtest "archive"
30 notmuch git -C tags.git -p '' archive | tar tf - | \
31     grep 20091117190054.GU3165@dottiness.seas.harvard.edu | sort > OUTPUT
32 cat <<EOF > EXPECTED
33 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/
34 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/inbox
35 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/signed
36 tags/20091117190054.GU3165@dottiness.seas.harvard.edu/unread
37 EOF
38 notmuch git -C tags.git -p '' checkout
39 test_expect_equal_file EXPECTED OUTPUT
40
41 test_begin_subtest "status"
42 notmuch tag +test id:20091117190054.GU3165@dottiness.seas.harvard.edu
43 notmuch git -C tags.git -p '' status > OUTPUT
44 cat <<EOF > EXPECTED
45 A       20091117190054.GU3165@dottiness.seas.harvard.edu        test
46 EOF
47 notmuch git -C tags.git -p '' checkout
48 test_expect_equal_file EXPECTED OUTPUT
49
50 test_begin_subtest "fetch"
51 notmuch tag +test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
52 notmuch git -C remote.git -p '' commit
53 notmuch tag -test2 id:20091117190054.GU3165@dottiness.seas.harvard.edu
54 notmuch git -C tags.git -p '' fetch
55 notmuch git -C tags.git -p '' status > OUTPUT
56 cat <<EOF > EXPECTED
57  a      20091117190054.GU3165@dottiness.seas.harvard.edu        test2
58 EOF
59 notmuch git -C tags.git -p '' checkout
60 test_expect_equal_file EXPECTED OUTPUT
61
62 test_begin_subtest "merge"
63 notmuch git -C tags.git -p '' merge
64 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
65 cat <<EOF > EXPECTED
66 +inbox +signed +test2 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
67 EOF
68 test_expect_equal_file EXPECTED OUTPUT
69
70 test_begin_subtest "push"
71 notmuch tag +test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
72 notmuch git -C tags.git -p '' commit
73 notmuch tag -test3 id:20091117190054.GU3165@dottiness.seas.harvard.edu
74 notmuch git -C tags.git -p '' push
75 notmuch git -C remote.git -p '' checkout
76 notmuch dump id:20091117190054.GU3165@dottiness.seas.harvard.edu | grep -v '^#' > OUTPUT
77 cat <<EOF > EXPECTED
78 +inbox +signed +test2 +test3 +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
79 EOF
80 test_expect_equal_file EXPECTED OUTPUT
81
82 test_begin_subtest "environment passed through when run as 'notmuch git'"
83 env NMBGIT=foo NMBPREFIX=bar NOTMUCH_PROFILE=default notmuch git -C tags.git -p '' -ldebug status |& \
84     grep '^env ' | notmuch_dir_sanitize > OUTPUT
85 cat <<EOF > EXPECTED
86 env NMBGIT = foo
87 env NMBPREFIX = bar
88 env NOTMUCH_PROFILE = default
89 env NOTMUCH_CONFIG = CWD/notmuch-config
90 EOF
91 test_expect_equal_file EXPECTED OUTPUT
92
93 test_done