about summary refs log tree commit diff
path: root/contrib/mw-to-git/t/push-pull-tests.sh
blob: 9da2dc5ff03699305613612225aba34bd5ff1611 (plain) (blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
test_push_pull () {

	test_expect_success 'Git pull works after adding a new wiki page' '
		wiki_reset &&

		git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
		wiki_editpage Foo "page created after the git clone" false &&

		(
			cd mw_dir_1 &&
			git pull
		) &&

		wiki_getallpage ref_page_1 &&
		test_diff_directories mw_dir_1 ref_page_1
	'

	test_expect_success 'Git pull works after editing a wiki page' '
		wiki_reset &&

		wiki_editpage Foo "page created before the git clone" false &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
		wiki_editpage Foo "new line added on the wiki" true &&

		(
			cd mw_dir_2 &&
			git pull
		) &&

		wiki_getallpage ref_page_2 &&
		test_diff_directories mw_dir_2 ref_page_2
	'

	test_expect_success 'git pull works on conflict handled by auto-merge' '
		wiki_reset &&

		wiki_editpage Foo "1 init
3
5
	" false &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_3 &&

		wiki_editpage Foo "1 init
2 content added on wiki after clone
3
5
	" false &&

		(
			cd mw_dir_3 &&
		echo "1 init
3
4 content added on git after clone
5
" >Foo.mw &&
			git commit -am "conflicting change on foo" &&
			git pull &&
			git push
		)
	'

	test_expect_success 'Git push works after adding a file .mw' '
		wiki_reset &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_4 &&
		wiki_getallpage ref_page_4 &&
		(
			cd mw_dir_4 &&
			test_path_is_missing Foo.mw &&
			touch Foo.mw &&
			echo "hello world" >>Foo.mw &&
			git add Foo.mw &&
			git commit -m "Foo" &&
			git push
		) &&
		wiki_getallpage ref_page_4 &&
		test_diff_directories mw_dir_4 ref_page_4
	'

	test_expect_success 'Git push works after editing a file .mw' '
		wiki_reset &&
		wiki_editpage "Foo" "page created before the git clone" false &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_5 &&

		(
			cd mw_dir_5 &&
			echo "new line added in the file Foo.mw" >>Foo.mw &&
			git commit -am "edit file Foo.mw" &&
			git push
		) &&

		wiki_getallpage ref_page_5 &&
		test_diff_directories mw_dir_5 ref_page_5
	'

	test_expect_failure 'Git push works after deleting a file' '
		wiki_reset &&
		wiki_editpage Foo "wiki page added before git clone" false &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&

		(
			cd mw_dir_6 &&
			git rm Foo.mw &&
			git commit -am "page Foo.mw deleted" &&
			git push
		) &&

		test_must_fail wiki_page_exist Foo
	'

	test_expect_success 'Merge conflict expected and solving it' '
		wiki_reset &&

		git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
		wiki_editpage Foo "1 conflict
3 wiki
4" false &&

		(
			cd mw_dir_7 &&
		echo "1 conflict
2 git
4" >Foo.mw &&
			git add Foo.mw &&
			git commit -m "conflict created" &&
			test_must_fail git pull &&
			"$PERL_PATH" -pi -e "s/[<=>].*//g" Foo.mw &&
			git commit -am "merge conflict solved" &&
			git push
		)
	'

	test_expect_failure 'git pull works after deleting a wiki page' '
		wiki_reset &&
		wiki_editpage Foo "wiki page added before the git clone" false &&
		git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&

		wiki_delete_page Foo &&
		(
			cd mw_dir_8 &&
			git pull &&
			test_path_is_missing Foo.mw
		)
	'
}