Skip to content

Commit

Permalink
add sql int max value check
Browse files Browse the repository at this point in the history
  • Loading branch information
berkut1 committed Jun 11, 2024
1 parent 42e93dc commit 4b48108
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class SolidcpHostingSpace implements AggregateRoot
{
use EventsTrait;

private const int PSQL_INT_MAX = 2147483647;

#[ORM\Id]
#[ORM\Column(name: "id", type: Types::INTEGER, nullable: false)]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
Expand Down Expand Up @@ -65,6 +67,9 @@ public function __construct(
$this->solidCpIdHostingSpace = $solidCpIdHostingSpace;
$this->name = $name;
$this->maxActiveNumber = $maxActiveNumber;
if($maxReservedMemoryKb > self::PSQL_INT_MAX){
throw new \DomainException("This value $maxReservedMemoryKb is too big than MAX ". self::PSQL_INT_MAX);
}
$this->maxReservedMemoryKb = $maxReservedMemoryKb;
$this->spaceQuotaGb = $spaceQuotaGb;
$this->enabled = $enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ public function testSuccess(): void
self::assertTrue($hostingSpace->isEnabled());
}

public function testFault(): void
{
self::expectException(\DomainException::class);

(new SolidcpHostingSpaceBuilder($this->solidcpServer, 123))
->withDetails(
'Test Hosting Space',
50,
37373737 * 1024,
360)
->build();
}

public function testRecordEvent(): void
{
$hostingSpace = (new SolidcpHostingSpaceBuilder($this->solidcpServer, 123))->build();
Expand Down

0 comments on commit 4b48108

Please sign in to comment.