File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 "Thenativeweb\\ Eventsourcingdb\\ Tests\\ " : " tests/"
1414 },
1515 "files" : [
16- " tests/getImageVersionFromDockerfile.php"
16+ " tests/Fn/ getImageVersionFromDockerfile.php"
1717 ]
1818 },
1919 "authors" : [
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ enum BoundType: string
1212 case EXCLUSIVE = 'exclusive ' ;
1313}
1414
15- class Bound implements JsonSerializable
15+ final readonly class Bound implements JsonSerializable
1616{
1717 public function __construct (
1818 public string $ id ,
Original file line number Diff line number Diff line change @@ -42,18 +42,42 @@ public function withPort(int $port): self
4242 return $ this ;
4343 }
4444
45+ /**
46+ * @throws Exception
47+ */
4548 public function start (): void
4649 {
47- $ container =
48- (new GenericContainer ("{$ this ->imageName }: {$ this ->imageTag }" ))
49- ->withExposedPorts ($ this ->internalPort )
50- ->withCommand ([
51- 'run ' ,
52- '--api-token ' , $ this ->apiToken ,
53- '--data-directory-temporary ' ,
54- '--http-enabled ' ,
55- '--https-enabled=false ' ,
56- ]);
50+ $ container = null ;
51+ $ retryCount = 5 ;
52+ while ($ retryCount ) {
53+ try {
54+ $ container =
55+ (new GenericContainer ("{$ this ->imageName }: {$ this ->imageTag }" ))
56+ ->withExposedPorts ($ this ->internalPort )
57+ ->withCommand ([
58+ 'run ' ,
59+ '--api-token ' , $ this ->apiToken ,
60+ '--data-directory-temporary ' ,
61+ '--http-enabled ' ,
62+ '--https-enabled=false ' ,
63+ ]);
64+
65+ } catch (Exception $ exception ) {
66+ --$ retryCount ;
67+
68+ $ exceptionMessage = $ exception ->getMessage ();
69+
70+ sleep (6 );
71+ }
72+
73+ if ($ container instanceof GenericContainer) {
74+ break ;
75+ }
76+ }
77+
78+ if (!$ container instanceof GenericContainer) {
79+ exit ($ exceptionMessage ?? 'Failed to create container ' );
80+ }
5781
5882 $ this ->container = $ container ->start ();
5983
Original file line number Diff line number Diff line change 66
77use JsonSerializable ;
88
9- class EventType implements JsonSerializable
9+ final readonly class EventType implements JsonSerializable
1010{
1111 public function __construct (
1212 public string $ eventType ,
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ enum ObserveIfEventIsMissing: string
1212 case WAIT_FOR_EVENT = 'wait-for-event ' ;
1313}
1414
15- class ObserveFromLatestEvent implements JsonSerializable
15+ final readonly class ObserveFromLatestEvent implements JsonSerializable
1616{
1717 public function __construct (
1818 public string $ subject ,
@@ -31,7 +31,7 @@ public function jsonSerialize(): array
3131 }
3232}
3333
34- class ObserveEventsOptions implements JsonSerializable
34+ final readonly class ObserveEventsOptions implements JsonSerializable
3535{
3636 public function __construct (
3737 public bool $ recursive ,
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ enum ReadIfEventIsMissing: string
1818 case READ_EVERYTHING = 'read-everything ' ;
1919}
2020
21- class ReadFromLatestEvent implements JsonSerializable
21+ final readonly class ReadFromLatestEvent implements JsonSerializable
2222{
2323 public function __construct (
2424 public string $ subject ,
@@ -37,7 +37,7 @@ public function jsonSerialize(): array
3737 }
3838}
3939
40- class ReadEventsOptions implements JsonSerializable
40+ final readonly class ReadEventsOptions implements JsonSerializable
4141{
4242 public function __construct (
4343 public bool $ recursive = false ,
Original file line number Diff line number Diff line change 66
77use Thenativeweb \Eventsourcingdb \Client ;
88use Thenativeweb \Eventsourcingdb \Container ;
9+ use function Thenativeweb \Eventsourcingdb \Tests \Fn \getImageVersionFromDockerfile ;
910
1011trait ClientTestTrait
1112{
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5- namespace Thenativeweb \Eventsourcingdb \Tests ;
5+ namespace Thenativeweb \Eventsourcingdb \Tests \ Fn ;
66
77use RuntimeException ;
88
99function getImageVersionFromDockerfile (): string
1010{
11- $ dockerfile = __DIR__ . '/../docker/Dockerfile ' ;
11+ $ dockerfile = __DIR__ . '/../../ docker/Dockerfile ' ;
1212
1313 if (!file_exists ($ dockerfile )) {
1414 throw new RuntimeException ('Dockerfile not found at ' . $ dockerfile );
You can’t perform that action at this time.
0 commit comments