Skip to content

Commit

Permalink
fix ci tests (run more containers)
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Feb 27, 2024
1 parent 46862b3 commit c5dd2fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ jobs:
run: composer install --prefer-dist --no-interaction --no-suggest

- name: Run initial testing Docker container
run: docker run --name docker_php_initial_container -d alpine:3.18
run: |
docker run --name docker_php_initial_container -d alpine:3.18
docker run --name docker_php_initial_container_2 -d node:20-alpine
- name: Execute tests
run: vendor/bin/pest -c phpunit.dist.xml --coverage-clover clover.xml
Expand Down
15 changes: 9 additions & 6 deletions src/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function head(string $path, array|RequestQuery $params = []): mixed
return $this->executeRequest($request);
}

public function post(string $path, $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
public function post(string $path, string|array $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
{
$this->contentType($contentType ?? static::JSON_CONTENT_TYPE);

Expand All @@ -106,7 +106,7 @@ public function post(string $path, $body = null, array|RequestQuery $params = []
return $this->executeRequest($request);
}

public function put(string $path, $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
public function put(string $path, string|array $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
{
$this->contentType($contentType ?? static::JSON_CONTENT_TYPE);

Expand All @@ -118,14 +118,18 @@ public function put(string $path, $body = null, array|RequestQuery $params = [],
return $this->executeRequest($request);
}

public function patch(string $path, $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
public function patch(string $path, string|array $body = null, array|RequestQuery $params = [], ?string $contentType = null): mixed
{
$this->contentType($contentType ?? static::JSON_CONTENT_TYPE);

$request = $this->requestFactory->createRequest(
'PATCH',
$this->baseUrl . $path . $this->queryToString($params)
)->withBody($this->applySentBodyParsing($body));
);

if ($body) {
$request->withBody($this->applySentBodyParsing($body));
}

return $this->executeRequest($request);
}
Expand Down Expand Up @@ -174,11 +178,10 @@ private function executeRequest(RequestInterface $request): mixed
/**
* Get parsed body using Content-Type header.
*/
private function applySentBodyParsing(mixed $body): StreamInterface
private function applySentBodyParsing(string|array $body): StreamInterface
{
$parsedBody = match ($this->headers['Content-Type'] ?? null) {
static::JSON_CONTENT_TYPE => json_encode($body),
static::RAW_CONTENT_TYPE => $body,
// TODO:
// static::STREAM_CONTENT_TYPE =>
default => $body,
Expand Down
8 changes: 4 additions & 4 deletions src/Endpoints/Containers.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ public function stats(string $id, ?ContainersStatsQuery $query = null): mixed

public function start(string $id, ?ContainersStartQuery $query = null): mixed
{
return $this->client->post(self::PATH . "/{$id}/start", $query ?? []);
return $this->client->post(self::PATH . "/{$id}/start", null, $query ?? []);
}

public function stop(string $id, ?ContainersStopQuery $query = null): mixed
{
return $this->client->post(self::PATH . "/{$id}/stop", $query ?? []);
return $this->client->post(self::PATH . "/{$id}/stop", null, $query ?? []);
}

public function restart(string $id, ?ContainersRestartQuery $query = null): mixed
{
return $this->client->post(self::PATH . "/{$id}/restart", $query ?? []);
return $this->client->post(self::PATH . "/{$id}/restart", null, $query ?? []);
}

public function kill(string $id, ?ContainersKillQuery $query = null): mixed
{
return $this->client->post(self::PATH . "/{$id}/kill", $query ?? []);
return $this->client->post(self::PATH . "/{$id}/kill", null, $query ?? []);
}

public function update(string $id, array $body): mixed
Expand Down

0 comments on commit c5dd2fe

Please sign in to comment.