-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathdb-check.feature
More file actions
173 lines (145 loc) · 4.53 KB
/
db-check.feature
File metadata and controls
173 lines (145 loc) · 4.53 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Feature: Check the database
@require-mysql-or-mariadb
Scenario: Run db check to check the database
Given a WP install
When I run `wp db check`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
"""
And STDOUT should contain:
"""
Success: Database checked.
"""
@require-mysql-or-mariadb
Scenario: db check with --quiet flag should only show errors
Given a WP install
When I run `wp db check --quiet`
Then STDOUT should be empty
@require-mysql-or-mariadb
Scenario: db check can explicitly pass --silent to mysqlcheck
Given a WP install
When I run `wp db check --silent`
Then STDOUT should not contain:
"""
wp_cli_test.wp_users
"""
And STDOUT should contain:
"""
Success: Database checked.
"""
@require-mysql-or-mariadb
Scenario: Run db check with MySQL defaults to check the database
Given a WP install
When I run `wp db check --defaults`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
"""
And STDOUT should contain:
"""
Success: Database checked.
"""
@require-mysql-or-mariadb
Scenario: Run db check with --no-defaults to check the database
Given a WP install
When I run `wp db check --no-defaults`
Then STDOUT should contain:
"""
wp_cli_test.wp_users
"""
And STDOUT should contain:
"""
Success: Database checked.
"""
@require-mysql-or-mariadb
Scenario: Run db check with passed-in options
Given a WP install
When I run `wp db check --dbuser=wp_cli_test`
Then STDOUT should contain:
"""
Success: Database checked.
"""
When I run `wp db check --dbpass=password1`
Then STDOUT should contain:
"""
Success: Database checked.
"""
When I run `wp db check --dbuser=wp_cli_test --dbpass=password1`
Then STDOUT should contain:
"""
Success: Database checked.
"""
When I try `wp db check --dbuser=no_such_user`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty
When I try `wp db check --dbpass=no_such_pass`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty
When I try `wp db check --dbuser=wp_cli_test --verbose`
Then the return code should be 0
And STDOUT should contain:
"""
Success: Database checked.
"""
# '--user' is ignored.
When I try `wp db check --user=no_such_user`
Then STDOUT should contain:
"""
Success: Database checked.
"""
# '--password' works, but MySQL may (depending on version) print warning to STDERR
When I try `wp db check --password=password1`
Then the return code should be 0
# Match STDERR containing "insecure" or empty STDERR.
And STDERR should match /^(?:.+insecure.+|)$/
And STDOUT should contain:
"""
Success: Database checked.
"""
# Bad '--password' works in that it causes access fail.
When I try `wp db check --password=no_such_pass`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty
# '--dbpass' overrides '--password'.
When I run `wp db check --dbpass=password1 --password=no_such_pass`
Then STDOUT should contain:
"""
Success: Database checked.
"""
When I try `wp db check --dbpass=no_such_pass --password=password1`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty
@require-mysql-or-mariadb
Scenario: MySQL defaults are available as appropriate with --defaults flag
Given a WP install
When I try `wp db check --defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) %s#
When I try `wp db check --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s#
When I try `wp db check --no-defaults --debug`
Then STDERR should match #Debug \(db\): Running shell command: /usr/bin/env (mysqlcheck|mariadb-check) --no-defaults %s#
@require-sqlite
Scenario: SQLite commands that show warnings
Given a WP install
When I try `wp db check`
Then STDERR should contain:
"""
Warning: Database check is not supported for SQLite databases
"""