61
61
import static io .ballerina .cli .cmd .CommandOutputUtils .getOutput ;
62
62
import static io .ballerina .cli .cmd .CommandOutputUtils .readFileAsString ;
63
63
import static io .ballerina .cli .cmd .CommandOutputUtils .replaceDependenciesTomlContent ;
64
+ import static io .ballerina .cli .cmd .CommandUtil .USER_HOME ;
64
65
import static io .ballerina .cli .utils .OsUtils .isWindows ;
65
66
import static io .ballerina .projects .util .ProjectConstants .BUILD_FILE ;
66
67
import static io .ballerina .projects .util .ProjectConstants .DEPENDENCIES_TOML ;
@@ -433,13 +434,35 @@ public void testTestEmptyProjectWithBuildTools() throws IOException {
433
434
Assert .assertEquals (buildLog .replace ("\r " , "" ), getOutput ("test-empty-project-with-build-tools.txt" ));
434
435
}
435
436
436
- @ Test (description = "Test the emission of testable fat jar for a project with tests" )
437
+ @ Test (description = "Test --cloud=k8s flag with a project with tests" )
438
+ public void testTestWithCloudK8s () throws IOException {
439
+ Path projectPath = this .testResources .resolve ("validProjectWithTests" );
440
+ ProjectUtils .deleteDirectory (projectPath .resolve ("target" ));
441
+ System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
442
+ Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
443
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
444
+ TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
445
+ new CommandLine (testCommand ).parseArgs ("--cloud=k8s" );
446
+ testCommand .execute ();
447
+
448
+ String buildLog = readOutput (true );
449
+ Assert .assertEquals (buildLog .replace ("\r " , "" ), getOutput ("test-project.txt" ));
450
+
451
+ Path targetDir = projectPath .resolve ("target" );
452
+ Path testableJar = targetDir .resolve ("bin/tests/winery-testable.jar" );
453
+ Assert .assertFalse (Files .exists (testableJar ));
454
+ Path mainArgsFile = testableJar .getParent ().resolve (TEST_RUNTIME_MAIN_ARGS_FILE );
455
+ Assert .assertFalse (Files .exists (mainArgsFile ));
456
+ }
457
+
458
+ @ Test (description = "Test the emission of testable fat jar for a project with tests" ,
459
+ dependsOnMethods = "testTestWithCloudK8s" )
437
460
public void testTestableFatJarEmission () {
438
461
Path projectPath = this .testResources .resolve ("validProjectWithTests" );
439
462
System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
440
463
441
464
Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
442
- System .setProperty ("user.home" , mockedLocalRepo .toString ());
465
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
443
466
444
467
TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
445
468
new CommandLine (testCommand ).parseArgs ("--cloud=docker" );
@@ -494,7 +517,7 @@ public void testEmissionOfTestableFatJarForProjectWithMocking() throws IOExcepti
494
517
System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
495
518
496
519
Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
497
- System .setProperty ("user.home" , mockedLocalRepo .toString ());
520
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
498
521
499
522
TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
500
523
new CommandLine (testCommand ).parseArgs ("--cloud=docker" );
@@ -556,7 +579,7 @@ public void testEmissionOfSingleFatJarForCloudAndGraalVM() throws IOException {
556
579
System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
557
580
558
581
Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
559
- System .setProperty ("user.home" , mockedLocalRepo .toString ());
582
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
560
583
561
584
TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
562
585
new CommandLine (testCommand ).parseArgs ("--cloud=docker" , "--graalvm" );
@@ -580,7 +603,7 @@ public void testEmissionOfMultipleFatJarsForProjectWithMockingForCloudAndGraalVM
580
603
System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
581
604
582
605
Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
583
- System .setProperty ("user.home" , mockedLocalRepo .toString ());
606
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
584
607
585
608
TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
586
609
new CommandLine (testCommand ).parseArgs ("--cloud=docker" , "--graalvm" );
@@ -654,7 +677,7 @@ public void testEmissionOfTestableFatJarForSingleTestBalFile() {
654
677
System .setProperty (ProjectConstants .USER_DIR , projectPath .toString ());
655
678
656
679
Path mockedLocalRepo = this .testResources .resolve ("mocked-local-repo" );
657
- System .setProperty ("user.home" , mockedLocalRepo .toString ());
680
+ System .setProperty (USER_HOME , mockedLocalRepo .toString ());
658
681
659
682
TestCommand testCommand = new TestCommand (projectPath , printStream , printStream , false );
660
683
new CommandLine (testCommand ).parseArgs ("--cloud=docker" , "main_tests.bal" );
0 commit comments