Skip to content

Commit

Permalink
Expand provided tests to test with "--no-defaults" as well as "--defa…
Browse files Browse the repository at this point in the history
…ults" flag
  • Loading branch information
Chris Wiegman committed Jan 8, 2020
1 parent 70ead30 commit 222fc3d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
19 changes: 19 additions & 0 deletions features/db-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ Feature: Check the database
Success: Database checked.
"""

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.
"""

Scenario: Run db check with passed-in options
Given a WP install

Expand Down Expand Up @@ -125,3 +138,9 @@ Feature: Check the database
"""
Debug (db): Running shell command: /usr/bin/env mysqlcheck --no-defaults %s
"""

When I try `wp db check --no-defaults --debug`
Then STDERR should contain:
"""
Debug (db): Running shell command: /usr/bin/env mysqlcheck --no-defaults %s
"""
15 changes: 15 additions & 0 deletions features/db-export.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ Feature: Export a WordPress database
-- MySQL dump
"""

Scenario: Export database with mysql --no-defaults to STDOUT
Given a WP install

When I run `wp db export --no-defaults -`
Then STDOUT should contain:
"""
-- MySQL dump
"""

Scenario: Export database with passed-in options
Given a WP install

Expand Down Expand Up @@ -83,3 +92,9 @@ Feature: Export a WordPress database
"""
Debug (db): Running initial shell command: /usr/bin/env mysqldump --no-defaults
"""

When I try `wp db export --no-defaults --debug`
Then STDERR should contain:
"""
Debug (db): Running initial shell command: /usr/bin/env mysqldump --no-defaults
"""
18 changes: 18 additions & 0 deletions features/db-import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ Feature: Import a WordPress database
Success: Imported from 'wp_cli_test.sql'.
"""

Scenario: Import from database name path by default with --no-defaults
Given a WP install

When I run `wp db export wp_cli_test.sql`
Then the wp_cli_test.sql file should exist

When I run `wp db import --no-defaults`
Then STDOUT should be:
"""
Success: Imported from 'wp_cli_test.sql'.
"""

Scenario: Import from STDIN
Given a WP install

Expand Down Expand Up @@ -133,3 +145,9 @@ Feature: Import a WordPress database
"""
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
"""

When I try `wp db import --no-defaults --debug`
Then STDERR should contain:
"""
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
"""
23 changes: 23 additions & 0 deletions features/db-query.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ Feature: Query the database with WordPress' MySQL config
"""
And STDOUT should be empty

Scenario: Database querying with --nodefaults and passed-in options
Given a WP install

When I run `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=wp_cli_test --html`
Then STDOUT should contain:
"""
<TABLE
"""

When I try `wp db query --no-defaults "SELECT COUNT(ID) FROM wp_posts;" --dbuser=no_such_user`
Then the return code should not be 0
And STDERR should contain:
"""
Access denied
"""
And STDOUT should be empty

Scenario: MySQL defaults are available as appropriate with --defaults flag
Given a WP install

Expand All @@ -69,3 +86,9 @@ Feature: Query the database with WordPress' MySQL config
"""
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
"""

When I try `wp db query --no-defaults --debug`
Then STDERR should contain:
"""
Debug (db): Running shell command: /usr/bin/env mysql --no-defaults --no-auto-rehash
"""

0 comments on commit 222fc3d

Please sign in to comment.