-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathdb-size.feature
More file actions
292 lines (224 loc) · 7.03 KB
/
db-size.feature
File metadata and controls
292 lines (224 loc) · 7.03 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# Assumes wp_cli_test has a database size of around 655,360 bytes.
Feature: Display database size
@require-mysql-or-mariadb
Scenario: Display only database size for a WordPress install
Given a WP install
When I run `wp db size`
Then STDOUT should contain:
"""
wp_cli_test
"""
And STDOUT should contain:
"""
B
"""
@require-sqlite
Scenario: Display only database size for a WordPress install
Given a WP install
When I run `wp db size`
Then STDOUT should contain:
"""
.ht.sqlite
"""
And STDOUT should contain:
"""
B
"""
Scenario: Display only table sizes for a WordPress install
Given a WP install
When I run `wp db size --tables`
Then STDOUT should match /wp_posts\s+\d+ B/
But STDOUT should not contain:
"""
wp_cli_test
"""
@require-mysql-or-mariadb
Scenario: Display only database size in a human readable format for a WordPress install
Given a WP install
When I run `wp db size --human-readable`
Then STDOUT should contain:
"""
wp_cli_test
"""
And STDOUT should contain:
"""
KB
"""
When I try `wp db size --human-readable --size_format=b`
Then the return code should not be 0
And STDERR should contain:
"""
Cannot use --size_format and --human-readable arguments at the same time.
"""
And STDOUT should be empty
@require-sqlite
Scenario: Display only database size in a human readable format for a WordPress install
Given a WP install
When I run `wp db size --human-readable`
Then STDOUT should contain:
"""
.ht.sqlite
"""
And STDOUT should contain:
"""
KB
"""
Scenario: Display only table sizes in a human readable format for a WordPress install
Given a WP install
When I run `wp db size --tables --human-readable`
Then STDOUT should contain:
"""
wp_posts
"""
And STDOUT should contain:
"""
KB
"""
But STDOUT should not contain:
"""
wp_cli_test
"""
When I try `wp db size --tables --human-readable --size_format=b`
Then the return code should not be 0
And STDERR should contain:
"""
Cannot use --size_format and --human-readable arguments at the same time.
"""
And STDOUT should be empty
Scenario: Display only database size in bytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=b`
Then STDOUT should be a number
Scenario: Display only database size in kilobytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=kb`
Then STDOUT should be a number
Scenario: Display only database size in megabytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=mb`
Then STDOUT should be a number
Scenario: Display only database size in gigabytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=gb`
Then STDOUT should be a number
Scenario: Display only database size in terabytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=tb`
Then STDOUT should be a number
Scenario: Display only database size in Kibibytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=KB`
Then STDOUT should be a number
Scenario: Display only database size in Mebibytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=MB`
Then STDOUT should be a number
Scenario: Display only database size in Gibibytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=GB`
Then STDOUT should be a number
Scenario: Display only database size in Tebibytes for a WordPress install
Given a WP install
When I run `wp db size --size_format=TB`
Then STDOUT should be a number
Scenario: Display only database size in megabytes with specific precision for a WordPress install
Given a WP install
When I run `wp db size --size_format=mb --decimals=0`
Then STDOUT should not contain:
"""
.
"""
And STDOUT should not contain:
"""
MB
"""
When I run `wp db size --size_format=mb --decimals=1`
Then STDOUT should contain:
"""
.
"""
And STDOUT should not contain:
"""
MB
"""
@require-mysql-or-mariadb
Scenario: Display database size in bytes with specific format for a WordPress install
Given a WP install
When I run `wp db size --size_format=b --format=csv`
Then STDOUT should contain:
"""
Name,Size
wp_cli_test,"
"""
But STDOUT should not be a number
When I run `wp db size --size_format=b --format=json`
Then STDOUT should contain:
"""
[{"Name":"wp_cli_test","Size":"
"""
But STDOUT should not be a number
@require-sqlite
Scenario: Display database size in bytes with specific format for a WordPress install
Given a WP install
When I run `wp db size --size_format=b --format=csv`
Then STDOUT should match /Name,Size\n\.ht\.sqlite(\.php)?,"/
But STDOUT should not be a number
When I run `wp db size --size_format=b --format=json`
Then STDOUT should match /^\[\{"Name":"\.ht\.sqlite(\.php)?","Size":"/
But STDOUT should not be a number
Scenario: Display all table sizes for a WordPress install
Given a WP install
When I run `wp db size --all-tables --size_format=kb`
Then STDOUT should contain:
"""
wp_posts
"""
And STDOUT should contain:
"""
KB
"""
When I run `wp db size --all-tables-with-prefix --size_format=kb`
Then STDOUT should contain:
"""
wp_posts
"""
And STDOUT should contain:
"""
KB
"""
@broken
Scenario: Display ordered table names for a WordPress install
Given a WP install
And I run `wp site empty --yes`
When I run `wp db size --tables --order=asc --format=json`
Then STDOUT should contain:
"""
[{"Name":"wp_commentmeta",
"""
When I run `wp db size --tables --order=desc --format=json`
Then STDOUT should contain:
"""
[{"Name":"wp_users",
"""
@broken
Scenario: Display ordered table sizes for a WordPress install
Given a WP install
And I run `wp site empty --yes`
And I run `wp post generate --post_type=page --post_status=draft --count=300`
When I run `wp db size --tables --order=desc --orderby=size --format=json`
Then STDOUT should contain:
"""
[{"Name":"wp_posts",
"""
When I run `wp db size --tables --order=asc --orderby=size --format=json`
Then STDOUT should not contain:
"""
[{"Name":"wp_posts",
"""
Scenario: Display ordered table sizes for a WordPress install
Given a WP install
When I run `wp db size --tables --all-tables --orderby=size --order=desc --size_format=mb`
Then STDOUT should contain:
"""
wp_posts
"""