1test_push_pull () {
2
3 test_expect_success 'Git pull works after adding a new wiki page' '
4 wiki_reset &&
5
6 git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
7 wiki_editpage Foo "page created after the git clone" false &&
8
9 (
10 cd mw_dir_1 &&
11 git pull
12 ) &&
13
14 wiki_getallpage ref_page_1 &&
15 test_diff_directories mw_dir_1 ref_page_1
16 '
17
18 test_expect_success 'Git pull works after editing a wiki page' '
19 wiki_reset &&
20
21 wiki_editpage Foo "page created before the git clone" false &&
22 git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
23 wiki_editpage Foo "new line added on the wiki" true &&
24
25 (
26 cd mw_dir_2 &&
27 git pull
28 ) &&
29
30 wiki_getallpage ref_page_2 &&
31 test_diff_directories mw_dir_2 ref_page_2
32 '
33
34 test_expect_success 'git pull works on conflict handled by auto-merge' '
35 wiki_reset &&
36
37 wiki_editpage Foo "1 init
383
395
40 " false &&
41 git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
42
43 wiki_editpage Foo "1 init
442 content added on wiki after clone
453
465
47 " false &&
48
49 (
50 cd mw_dir_3 &&
51 echo "1 init
523
534 content added on git after clone
545
55" >Foo.mw &&
56 git commit -am "conflicting change on foo" &&
57 git pull &&
58 git push
59 )
60 '
61
62 test_expect_success 'Git push works after adding a file .mw' '
63 wiki_reset &&
64 git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
65 wiki_getallpage ref_page_4 &&
66 (
67 cd mw_dir_4 &&
68 test_path_is_missing Foo.mw &&
69 touch Foo.mw &&
70 echo "hello world" >>Foo.mw &&
71 git add Foo.mw &&
72 git commit -m "Foo" &&
73 git push
74 ) &&
75 wiki_getallpage ref_page_4 &&
76 test_diff_directories mw_dir_4 ref_page_4
77 '
78
79 test_expect_success 'Git push works after editing a file .mw' '
80 wiki_reset &&
81 wiki_editpage "Foo" "page created before the git clone" false &&
82 git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&
83
84 (
85 cd mw_dir_5 &&
86 echo "new line added in the file Foo.mw" >>Foo.mw &&
87 git commit -am "edit file Foo.mw" &&
88 git push
89 ) &&
90
91 wiki_getallpage ref_page_5 &&
92 test_diff_directories mw_dir_5 ref_page_5
93 '
94
95 test_expect_failure 'Git push works after deleting a file' '
96 wiki_reset &&
97 wiki_editpage Foo "wiki page added before git clone" false &&
98 git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
99
100 (
101 cd mw_dir_6 &&
102 git rm Foo.mw &&
103 git commit -am "page Foo.mw deleted" &&
104 git push
105 ) &&
106
107 test_must_fail wiki_page_exist Foo
108 '
109
110 test_expect_success 'Merge conflict expected and solving it' '
111 wiki_reset &&
112
113 git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
114 wiki_editpage Foo "1 conflict
1153 wiki
1164" false &&
117
118 (
119 cd mw_dir_7 &&
120 echo "1 conflict
1212 git
1224" >Foo.mw &&
123 git add Foo.mw &&
124 git commit -m "conflict created" &&
125 test_must_fail git pull &&
126 "$PERL_PATH" -pi -e "s/[<=>].*//g" Foo.mw &&
127 git commit -am "merge conflict solved" &&
128 git push
129 )
130 '
131
132 test_expect_failure 'git pull works after deleting a wiki page' '
133 wiki_reset &&
134 wiki_editpage Foo "wiki page added before the git clone" false &&
135 git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
136
137 wiki_delete_page Foo &&
138 (
139 cd mw_dir_8 &&
140 git pull &&
141 test_path_is_missing Foo.mw
142 )
143 '
144}