Skip to content

Commit 222fc3d

Browse files
author
Chris Wiegman
committed
Expand provided tests to test with "--no-defaults" as well as "--defaults" flag
1 parent 70ead30 commit 222fc3d

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

features/db-check.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ Feature: Check the database
2626
Success: Database checked.
2727
"""
2828

29+
Scenario: Run db check with --no-defaults to check the database
30+
Given a WP install
31+
32+
When I run `wp db check --no-defaults`
33+
Then STDOUT should contain:
34+
"""
35+
wp_cli_test.wp_users
36+
"""
37+
And STDOUT should contain:
38+
"""
39+
Success: Database checked.
40+
"""
41+
2942
Scenario: Run db check with passed-in options
3043
Given a WP install
3144

@@ -125,3 +138,9 @@ Feature: Check the database
125138
"""
126139
Debug (db): Running shell command: /usr/bin/env mysqlcheck --no-defaults %s
127140
"""
141+
142+
When I try `wp db check --no-defaults --debug`
143+
Then STDERR should contain:
144+
"""
145+
Debug (db): Running shell command: /usr/bin/env mysqlcheck --no-defaults %s
146+
"""

features/db-export.feature

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ Feature: Export a WordPress database
5252
-- MySQL dump
5353
"""
5454

55+
Scenario: Export database with mysql --no-defaults to STDOUT
56+
Given a WP install
57+
58+
When I run `wp db export --no-defaults -`
59+
Then STDOUT should contain:
60+
"""
61+
-- MySQL dump
62+
"""
63+
5564
Scenario: Export database with passed-in options
5665
Given a WP install
5766

@@ -83,3 +92,9 @@ Feature: Export a WordPress database
8392
"""
8493
Debug (db): Running initial shell command: /usr/bin/env mysqldump --no-defaults
8594
"""
95+
96+
When I try `wp db export --no-defaults --debug`
97+
Then STDERR should contain:
98+
"""
99+
Debug (db): Running initial shell command: /usr/bin/env mysqldump --no-defaults
100+
"""

features/db-import.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ Feature: Import a WordPress database
2424
Success: Imported from 'wp_cli_test.sql'.
2525
"""
2626

27+
Scenario: Import from database name path by default with --no-defaults
28+
Given a WP install
29+
30+
When I run `wp db export wp_cli_test.sql`
31+
Then the wp_cli_test.sql file should exist
32+
33+
When I run `wp db import --no-defaults`
34+
Then STDOUT should be:
35+
"""
36+
Success: Imported from 'wp_cli_test.sql'.
37+
"""
38+
2739
Scenario: Import from STDIN
2840
Given a WP install
2941

@@ -133,3 +145,9 @@ Feature: Import a WordPress database
133145
"""
134146
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
135147
"""
148+
149+
When I try `wp db import --no-defaults --debug`
150+
Then STDERR should contain:
151+
"""
152+
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
153+
"""

features/db-query.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ Feature: Query the database with WordPress' MySQL config
5555
"""
5656
And STDOUT should be empty
5757

58+
Scenario: Database querying with --nodefaults and passed-in options
59+
Given a WP install
60+
61+
When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
62+
Then STDOUT should contain:
63+
"""
64+
<TABLE
65+
"""
66+
67+
When I try `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=no_such_user`
68+
Then the return code should not be 0
69+
And STDERR should contain:
70+
"""
71+
Access denied
72+
"""
73+
And STDOUT should be empty
74+
5875
Scenario: MySQL defaults are available as appropriate with --defaults flag
5976
Given a WP install
6077

@@ -69,3 +86,9 @@ Feature: Query the database with WordPress' MySQL config
6986
"""
7087
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
7188
"""
89+
90+
When I try `wp db query --no-defaults --debug`
91+
Then STDERR should contain:
92+
"""
93+
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
94+
"""

0 commit comments

Comments
 (0)