Skip to content

Commit

Permalink
Update default httpbin url
Browse files Browse the repository at this point in the history
  • Loading branch information
OzzyCzech committed Jun 19, 2023
1 parent b34d2db commit f75bd10
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ jobs:
run: pip install httpbin gunicorn werkzeug==2.0.3
- name: run httpbin server
run: |
gunicorn -b 127.0.0.1:8000 httpbin:app &
gunicorn -b 127.0.0.1:80 httpbin:app &
- name: make integration
run: |
cd ./integration-tests && ./run
make -C integration-tests check HTTPIE_URL=http://127.0.0.1:8000
make -C integration-tests check
cat integration-tests/test-suite.log
# try:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ gunicorn httpbin:app
Then run the following command under `./integration-tests` directory

```shell
cd ./integration-tests
make check HTTPBIN_URL=http://127.0.0.1:80
make -C integration-tests check HTTPIE_URL=http://127.0.0.1:80
```

#### Running httpbin using Docker
Expand Down
37 changes: 19 additions & 18 deletions integration-tests/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/php
<?php
const DEFAULT_HTTPBIN_URL = 'http://127.0.0.1:80';

$errors = [];

/**
Expand All @@ -20,12 +22,10 @@ set_error_handler('errorHandler');

/**
* Load test cases the array of closures
* @var array $tests
*/
$tests = require_once __DIR__ . '/test_cases.php';

var_dump($tests);
/** @var array $tests */

echo '1..' . count($tests) . "\n";

foreach ($tests as $test) {
Expand All @@ -51,33 +51,31 @@ function source(Closure $test): string {
} catch (ReflectionException $e) {
return '';
}

}

/**
* Return host file
* Return full url
* @param string $path
* @return string
*/
function host(): string {
function url(string $path = ''): string {
global $argv;
if (isset($argv[1])) {
return parse_url($argv[1], PHP_URL_HOST);
return rtrim($argv[1], '/') . $path;
} elseif (getenv('HTTPBIN_URL')) {
return rtrim(getenv('HTTPBIN_URL'), '/') . $path;
} else {
return getenv('HTTPBIN_URL') ? parse_url(getenv('HTTPBIN_URL'), PHP_URL_HOST) : '127.0.0.1';
return DEFAULT_HTTPBIN_URL . $path;
}
}


/**
* @param string $path
* Return url host
* @return string
*/
function url(string $path): string {
global $argv;
if (isset($argv[1])) {
return rtrim($argv[1], '/') . $path;
} else {
return rtrim(getenv('HTTPBIN_URL') ?: 'http://127.0.0.1:80', '/') . $path;
}
function host(): string {
return parse_url(url(), PHP_URL_HOST) ?: '127.0.0.1';
}

/**
Expand All @@ -89,9 +87,12 @@ function check_result_for_path($path, array $args, array $checks): void {
foreach ($args as $flag => $arg) {
$argsString .= ' ' . (is_string($flag) ? $flag . ' ' . escapeshellarg($arg) : $arg);
}

$cli = __DIR__ . "/../minicrawler5 $argsString " . escapeshellarg(url($path));

echo $cli;

if (!file_exists(__DIR__ . '/../minicrawler5')) {
throw new TestFailedException("minicrawler5 not found in " . __DIR__ . "/../minicrawler5");
}

$result = shell_exec($cli);

Expand Down

0 comments on commit f75bd10

Please sign in to comment.