Git 2.42.2
[git.git] / contrib / mw-to-git / t / push-pull-tests.sh
blob9da2dc5ff03699305613612225aba34bd5ff1611
1 test_push_pull () {
3 test_expect_success 'Git pull works after adding a new wiki page' '
4 wiki_reset &&
6 git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
7 wiki_editpage Foo "page created after the git clone" false &&
10 cd mw_dir_1 &&
11 git pull
12 ) &&
14 wiki_getallpage ref_page_1 &&
15 test_diff_directories mw_dir_1 ref_page_1
18 test_expect_success 'Git pull works after editing a wiki page' '
19 wiki_reset &&
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 &&
26 cd mw_dir_2 &&
27 git pull
28 ) &&
30 wiki_getallpage ref_page_2 &&
31 test_diff_directories mw_dir_2 ref_page_2
34 test_expect_success 'git pull works on conflict handled by auto-merge' '
35 wiki_reset &&
37 wiki_editpage Foo "1 init
40 " false &&
41 git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&
43 wiki_editpage Foo "1 init
44 2 content added on wiki after clone
47 " false &&
50 cd mw_dir_3 &&
51 echo "1 init
53 4 content added on git after clone
55 " >Foo.mw &&
56 git commit -am "conflicting change on foo" &&
57 git pull &&
58 git push
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 &&
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
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 &&
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 ) &&
91 wiki_getallpage ref_page_5 &&
92 test_diff_directories mw_dir_5 ref_page_5
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 &&
101 cd mw_dir_6 &&
102 git rm Foo.mw &&
103 git commit -am "page Foo.mw deleted" &&
104 git push
105 ) &&
107 test_must_fail wiki_page_exist Foo
110 test_expect_success 'Merge conflict expected and solving it' '
111 wiki_reset &&
113 git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
114 wiki_editpage Foo "1 conflict
115 3 wiki
116 4" false &&
119 cd mw_dir_7 &&
120 echo "1 conflict
121 2 git
122 4" >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
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 &&
137 wiki_delete_page Foo &&
139 cd mw_dir_8 &&
140 git pull &&
141 test_path_is_missing Foo.mw