Skip to content

Commit

Permalink
chore(dev): Rename plural People to unified singular Person
Browse files Browse the repository at this point in the history
  • Loading branch information
leocavalcante committed Aug 15, 2023
1 parent 615b344 commit 41c2021
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
APP_NAME=skeleton
APP_NAME=rinha-de-backend
APP_ENV=dev

DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=hyperf
DB_DATABASE=opencodeco
DB_USERNAME=root
DB_PASSWORD=
DB_PASSWORD=opencodeco
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
DB_PREFIX=

REDIS_HOST=localhost
REDIS_AUTH=(null)
REDIS_PORT=6379
REDIS_DB=0
REDIS_DB=0
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

namespace App\Controller;

use App\Request\PeopleRequest;
use App\Request\PersonRequest;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Psr\Http\Message\ResponseInterface as MessageResponseInterface;

final class PeopleController
final class PersonController
{
public function create(PeopleRequest $request, ResponseInterface $response): MessageResponseInterface
public function create(PersonRequest $request, ResponseInterface $response): MessageResponseInterface
{
$person = $request->validated();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use Hyperf\Validation\Request\FormRequest;

class PeopleRequest extends FormRequest
final class PersonRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
Expand Down
10 changes: 5 additions & 5 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* @contact https://github.com/opencodeco/rinha-de-backend-2023-q3/discussions
* @license https://github.com/opencodeco/rinha-de-backend-2023-q3/blob/dev/LICENSE
*/
use App\Controller\PeopleController;
use App\Controller\PersonController;
use Hyperf\HttpServer\Router\Router;

Router::post('/pessoas', [PeopleController::class, 'create']);
Router::get('/pessoas/{id}', [PeopleController::class, 'show']);
Router::get('/pessoas', [PeopleController::class, 'search']);
Router::get('/contagem-pessoas', [PeopleController::class, 'count']);
Router::post('/pessoas', [PersonController::class, 'create']);
Router::get('/pessoas/{id}', [PersonController::class, 'show']);
Router::get('/pessoas', [PersonController::class, 'search']);
Router::get('/contagem-pessoas', [PersonController::class, 'count']);
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'
services:
db:
container_name: rinha-de-backend-db
image: mysql:8.1
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: opencodeco
MYSQL_DATABASE: opencodeco
volumes:
- ./migrations.sql:/docker-entrypoint-initdb.d/migrations.sql
ports:
- 3306:3306

networks:
default:
name: rinha-de-backend
7 changes: 7 additions & 0 deletions migrations.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
create table person(
id binary(16) primary key,
nick varchar(32) not null,
name varchar(100) not null,
birth date not null,
stack json
);
34 changes: 17 additions & 17 deletions test/Cases/CreatePeopleTest.php → test/Cases/CreatePersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* @internal
* @coversNothing
*/
final class CreatePeopleTest extends HttpTestCase
final class CreatePersonTest extends HttpTestCase
{
public function testCreatePeopleWithEmptyNickname(): void
public function testCreatePersonWithEmptyNickname(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -40,10 +40,10 @@ public function testCreatePeopleWithEmptyNickname(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithNullNickname(): void
public function testCreatePersonWithNullNickname(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -57,10 +57,10 @@ public function testCreatePeopleWithNullNickname(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithEmptyName(): void
public function testCreatePersonWithEmptyName(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -74,10 +74,10 @@ public function testCreatePeopleWithEmptyName(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithNullName(): void
public function testCreatePersonWithNullName(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -91,10 +91,10 @@ public function testCreatePeopleWithNullName(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithEmptyBirthDate(): void
public function testCreatePersonWithEmptyBirthDate(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -108,10 +108,10 @@ public function testCreatePeopleWithEmptyBirthDate(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithNullBirthDate(): void
public function testCreatePersonWithNullBirthDate(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -125,10 +125,10 @@ public function testCreatePeopleWithNullBirthDate(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeopleWithInvalidBirthDate(): void
public function testCreatePersonWithInvalidBirthDate(): void
{
/** @var Response $response */
$response = $this->request('post', '/pessoas', [
$response = $this->request('POST', '/pessoas', [
'headers' => [
'Content-Type' => 'application/json',
],
Expand All @@ -142,7 +142,7 @@ public function testCreatePeopleWithInvalidBirthDate(): void
assertSame(422, $response->getStatusCode());
}

public function testCreatePeople(): void
public function testCreatePerson(): void
{
/** @var Response $response */
$response = $this->request('POST', '/pessoas', [
Expand All @@ -156,6 +156,6 @@ public function testCreatePeople(): void
],
]);

assertSame(201, $response->getStatusCode());
assertSame(201, $response->getStatusCode(), $response->getBody()->getContents());
}
}

0 comments on commit 41c2021

Please sign in to comment.