22
33namespace RenokiCo \PhpK8s \Test ;
44
5+ use RenokiCo \PhpK8s \Enums \RestartPolicy ;
56use RenokiCo \PhpK8s \Instances \MountedVolume ;
67use RenokiCo \PhpK8s \Instances \Probe ;
78use RenokiCo \PhpK8s \K8s ;
@@ -10,6 +11,8 @@ class ContainerTest extends TestCase
1011{
1112 public function test_container_build ()
1213 {
14+ $ this ->assertNull (K8s::container ()->getRestartPolicy ());
15+
1316 $ container = K8s::container ();
1417
1518 $ volume = K8s::volume ()->awsEbs ('vol-1234 ' , 'ext3 ' );
@@ -21,6 +24,7 @@ public function test_container_build()
2124 ->addConfigMapRefs (['SECRET_TWO ' => ['cm_ref_name ' , 'cm_ref_key ' ]])
2225 ->addFieldRefs (['NODE_NAME ' => ['spec.nodeName ' ]])
2326 ->setArgs (['--test ' ])
27+ ->setRestartPolicy (RestartPolicy::ALWAYS )
2428 ->addPort (80 , 'TCP ' , 'http ' )
2529 ->addPort (443 , 'TCP ' , 'https ' )
2630 ->setMountedVolumes ([$ volume ->mountTo ('/some/path ' )]);
@@ -98,10 +102,15 @@ public function test_container_build()
98102 $ this ->assertStringEndsWith ('nginx:1.23 ' , $ container ->getImage ());
99103 $ this ->assertEquals ([], $ container ->getEnv ([]));
100104 $ this ->assertEquals (['--test ' ], $ container ->getArgs ());
105+ $ this ->assertEquals (RestartPolicy::ALWAYS , $ container ->getRestartPolicy ());
101106 $ this ->assertEquals ([
102107 ['name ' => 'http ' , 'protocol ' => 'TCP ' , 'containerPort ' => 80 ],
103108 ['name ' => 'https ' , 'protocol ' => 'TCP ' , 'containerPort ' => 443 ],
104109 ], $ container ->getPorts ());
110+
111+ $ stringPolicy = K8s::container ()->setRestartPolicy ('Never ' );
112+ $ this ->assertEquals (RestartPolicy::NEVER , $ stringPolicy ->getRestartPolicy ());
113+
105114 $ this ->assertEquals ('1Gi ' , $ container ->getMinMemory ());
106115 $ this ->assertEquals ('2Gi ' , $ container ->getMaxMemory ());
107116 $ this ->assertEquals ('500m ' , $ container ->getMinCpu ());
0 commit comments