Skip to content

Commit 0b70a31

Browse files
Copilotswissspidy
andcommitted
Replace env var tests with actual Git/SSH interaction tests
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 5ac3863 commit 0b70a31

3 files changed

Lines changed: 34 additions & 121 deletions

File tree

features/package-install.feature

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,46 +1263,19 @@ Feature: Install WP-CLI packages
12631263
"""
12641264
And STDOUT should be empty
12651265
1266-
Scenario: Install a package with --no-interaction flag sets environment variables
1266+
@github-api
1267+
Scenario: Install package with --no-interaction fails fast on Git authentication errors
12671268
Given an empty directory
1268-
And a composer.json file:
1269-
"""
1270-
{
1271-
"repositories": {
1272-
"test" : {
1273-
"type": "path",
1274-
"url": "./dummy-package/"
1275-
},
1276-
"wp-cli": {
1277-
"type": "composer",
1278-
"url": "https://wp-cli.org/package-index/"
1279-
}
1280-
}
1281-
}
1282-
"""
1283-
And a dummy-package/composer.json file:
1284-
"""
1285-
{
1286-
"name": "wp-cli/restful",
1287-
"description": "Test package for no-interaction flag",
1288-
"scripts": {
1289-
"post-install-cmd": [
1290-
"@php -r \"echo 'GIT_TERMINAL_PROMPT=' . getenv('GIT_TERMINAL_PROMPT') . PHP_EOL;\"",
1291-
"@php -r \"echo 'GIT_SSH_COMMAND=' . getenv('GIT_SSH_COMMAND') . PHP_EOL;\""
1292-
]
1293-
}
1294-
}
1295-
"""
1296-
When I run `WP_CLI_PACKAGES_DIR=. wp package install wp-cli/restful --no-interaction`
1297-
Then STDOUT should contain:
1298-
"""
1299-
GIT_TERMINAL_PROMPT=0
1300-
"""
1301-
And STDOUT should contain:
1302-
"""
1303-
GIT_SSH_COMMAND=ssh -o BatchMode=yes
1304-
"""
1305-
And STDOUT should contain:
1269+
1270+
# Try to install from a repository that requires authentication
1271+
# With --no-interaction and GIT_TERMINAL_PROMPT=0, Git will fail immediately
1272+
# instead of prompting for credentials
1273+
When I try `wp package install git@github.com:wp-cli-private-test/authentication-required.git --no-interaction`
1274+
Then the return code should be 1
1275+
# The command should fail fast without hanging
1276+
And STDERR should contain:
13061277
"""
1307-
Success: Package installed
1278+
Package installation failed
13081279
"""
1280+
# Git should report it couldn't authenticate, not prompt
1281+
And STDERR should match /fatal:|Could not read from remote repository|Repository not found/

features/package-update.feature

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -195,51 +195,21 @@ Feature: Update WP-CLI packages
195195
"""
196196
And the return code should be 1
197197

198-
Scenario: Update packages with --no-interaction flag sets environment variables
198+
@github-api
199+
Scenario: Update packages with --no-interaction completes without prompting
199200
Given an empty directory
200-
And a composer.json file:
201-
"""
202-
{
203-
"repositories": {
204-
"test" : {
205-
"type": "path",
206-
"url": "./dummy-package/"
207-
},
208-
"wp-cli": {
209-
"type": "composer",
210-
"url": "https://wp-cli.org/package-index/"
211-
}
212-
},
213-
"require": {
214-
"wp-cli/restful": "*"
215-
}
216-
}
217-
"""
218-
And a dummy-package/composer.json file:
219-
"""
220-
{
221-
"name": "wp-cli/restful",
222-
"version": "1.0.0",
223-
"description": "Test package for no-interaction flag",
224-
"scripts": {
225-
"post-update-cmd": [
226-
"@php -r \"echo 'GIT_TERMINAL_PROMPT=' . getenv('GIT_TERMINAL_PROMPT') . PHP_EOL;\"",
227-
"@php -r \"echo 'GIT_SSH_COMMAND=' . getenv('GIT_SSH_COMMAND') . PHP_EOL;\""
228-
]
229-
}
230-
}
231-
"""
232-
233-
When I run `WP_CLI_PACKAGES_DIR=. wp package update --no-interaction`
234-
Then STDOUT should contain:
235-
"""
236-
GIT_TERMINAL_PROMPT=0
237-
"""
238-
And STDOUT should contain:
201+
202+
# Install a real package
203+
When I run `wp package install danielbachhuber/wp-cli-reset-post-date-command`
204+
Then STDOUT should contain:
239205
"""
240-
GIT_SSH_COMMAND=ssh -o BatchMode=yes
206+
Success: Package installed.
241207
"""
242-
And STDOUT should contain:
208+
209+
# Update with --no-interaction should complete without hanging
210+
When I run `wp package update --no-interaction`
211+
Then STDOUT should contain:
243212
"""
244213
Packages updated.
245214
"""
215+
And STDERR should be empty

features/package.feature

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -209,50 +209,20 @@ Feature: Manage WP-CLI packages
209209
{NO_SUCH_PACKAGE_COMPOSER_JSON}
210210
"""
211211

212-
Scenario: Uninstall a package with --no-interaction flag sets environment variables
212+
@github-api
213+
Scenario: Uninstall a package with --no-interaction prevents Git credential prompts
213214
Given an empty directory
214-
And a composer.json file:
215-
"""
216-
{
217-
"repositories": {
218-
"test" : {
219-
"type": "path",
220-
"url": "./dummy-package/"
221-
},
222-
"wp-cli": {
223-
"type": "composer",
224-
"url": "https://wp-cli.org/package-index/"
225-
}
226-
},
227-
"require": {
228-
"wp-cli/restful": "*"
229-
}
230-
}
231-
"""
232-
And a dummy-package/composer.json file:
233-
"""
234-
{
235-
"name": "wp-cli/restful",
236-
"version": "1.0.0",
237-
"description": "Test package for no-interaction flag",
238-
"scripts": {
239-
"pre-uninstall-cmd": [
240-
"@php -r \"echo 'GIT_TERMINAL_PROMPT=' . getenv('GIT_TERMINAL_PROMPT') . PHP_EOL;\"",
241-
"@php -r \"echo 'GIT_SSH_COMMAND=' . getenv('GIT_SSH_COMMAND') . PHP_EOL;\""
242-
]
243-
}
244-
}
245-
"""
246215

247-
When I run `WP_CLI_PACKAGES_DIR=. wp package uninstall wp-cli/restful --no-interaction`
216+
# Install a real package first
217+
When I run `wp package install danielbachhuber/wp-cli-reset-post-date-command`
248218
Then STDOUT should contain:
249219
"""
250-
GIT_TERMINAL_PROMPT=0
251-
"""
252-
And STDOUT should contain:
253-
"""
254-
GIT_SSH_COMMAND=ssh -o BatchMode=yes
220+
Success: Package installed.
255221
"""
222+
223+
# Uninstall with --no-interaction should complete without hanging
224+
When I run `wp package uninstall danielbachhuber/wp-cli-reset-post-date-command --no-interaction`
225+
Then STDERR should be empty
256226
And STDOUT should contain:
257227
"""
258228
Success: Uninstalled package.

0 commit comments

Comments
 (0)