@@ -41,7 +41,7 @@ func TestBuildAddDependenciesFromHomeDir(t *testing.T) {
41
41
fileName := "cliTestFile.txt"
42
42
testFileRelPath , testFileAbs := createFileInHomeDir (t , fileName )
43
43
44
- test := buildAddDepsBuildInfoTestParams {description : "'rt bad' from home dir" , commandArgs : []string {testFileRelPath , "--recursive=false" }, expectedDependencies : []string {fileName }, buildName : tests .RtBuildName1 , buildNumber : "1" }
44
+ test := buildAddDepsBuildInfoTestParams {description : "'rt bad' from home dir" , commandArgs : []string {testFileRelPath , "--recursive=false" }, expectedDependencies : []string {fileName }, buildName : tests .RtBuildName1 , buildNumber : "1" , expectedModule : tests . RtBuildName1 }
45
45
collectDepsAndPublishBuild (test , false , t )
46
46
validateBuildAddDepsBuildInfo (t , test )
47
47
@@ -436,29 +436,33 @@ func TestBuildAddDependencies(t *testing.T) {
436
436
allFiles := []string {"a1.in" , "a2.in" , "a3.in" , "b1.in" , "b2.in" , "b3.in" , "c1.in" , "c2.in" , "c3.in" }
437
437
var badTests = []buildAddDepsBuildInfoTestParams {
438
438
// Collect the dependencies from the local file system (the --from-rt option is not used).
439
- {description : "'rt bad' simple cli" , commandArgs : []string {"testdata/a/*" }, expectedDependencies : allFiles },
440
- {description : "'rt bad' single file" , commandArgs : []string {"testdata/a/a1.in" }, expectedDependencies : []string {"a1.in" }},
441
- {description : "'rt bad' none recursive" , commandArgs : []string {"testdata/a/*" , "--recursive=false" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" }},
442
- {description : "'rt bad' special chars recursive" , commandArgs : []string {getSpecialCharFilePath ()}, expectedDependencies : []string {"a1.in" }},
443
- {description : "'rt bad' exclude command line wildcards" , commandArgs : []string {"testdata/a/*" , "--exclusions=*a2*;*a3.in" }, expectedDependencies : []string {"a1.in" , "b1.in" , "b2.in" , "b3.in" , "c1.in" , "c2.in" , "c3.in" }},
444
- {description : "'rt bad' spec" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .BuildAddDepsSpec )}, expectedDependencies : allFiles },
445
- {description : "'rt bad' two specFiles" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .BuildAddDepsDoubleSpec )}, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" , "b1.in" , "b2.in" , "b3.in" }},
446
- {description : "'rt bad' exclude command line regexp" , commandArgs : []string {"testdata/a/a(.*)" , "--exclusions=(.*)a2.*;.*a3.in" , "--regexp=true" }, expectedDependencies : []string {"a1.in" }},
439
+ {description : "'rt bad' simple cli" , commandArgs : []string {"testdata/a/*" }, expectedDependencies : allFiles , expectedModule : tests .RtBuildName1 },
440
+ {description : "'rt bad' simple cli" , commandArgs : []string {"testdata/a/*" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : allFiles , expectedModule : ModuleNameJFrogTest },
441
+ {description : "'rt bad' single file" , commandArgs : []string {"testdata/a/a1.in" }, expectedDependencies : []string {"a1.in" }, expectedModule : tests .RtBuildName1 },
442
+ {description : "'rt bad' none recursive" , commandArgs : []string {"testdata/a/*" , "--recursive=false" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" }, expectedModule : tests .RtBuildName1 },
443
+ {description : "'rt bad' none recursive" , commandArgs : []string {"testdata/a/*" , "--recursive=false" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" }, expectedModule : ModuleNameJFrogTest },
444
+ {description : "'rt bad' special chars recursive" , commandArgs : []string {getSpecialCharFilePath ()}, expectedDependencies : []string {"a1.in" }, expectedModule : tests .RtBuildName1 },
445
+ {description : "'rt bad' exclude command line wildcards" , commandArgs : []string {"testdata/a/*" , "--exclusions=*a2*;*a3.in" }, expectedDependencies : []string {"a1.in" , "b1.in" , "b2.in" , "b3.in" , "c1.in" , "c2.in" , "c3.in" }, expectedModule : tests .RtBuildName1 },
446
+ {description : "'rt bad' spec" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .BuildAddDepsSpec )}, expectedDependencies : allFiles , expectedModule : tests .RtBuildName1 },
447
+ {description : "'rt bad' two specFiles" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .BuildAddDepsDoubleSpec )}, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" , "b1.in" , "b2.in" , "b3.in" }, expectedModule : tests .RtBuildName1 },
448
+ {description : "'rt bad' exclude command line regexp" , commandArgs : []string {"testdata/a/a(.*)" , "--exclusions=(.*)a2.*;.*a3.in" , "--regexp=true" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : []string {"a1.in" }, expectedModule : ModuleNameJFrogTest },
447
449
448
450
// Collect the dependencies from Artifactory using the --from-rt option.
449
- {description : "'rt bad' simple cli" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--from-rt" }, expectedDependencies : allFiles },
450
- {description : "'rt bad' single file" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/a1.in" , "--from-rt" }, expectedDependencies : []string {"a1.in" }},
451
- {description : "'rt bad' none recursive" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--recursive=false" , "--from-rt" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" }},
452
- {description : "'rt bad' exclude command line wildcards" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--exclusions=*a2*;*a3.in" , "--from-rt" }, expectedDependencies : []string {"a1.in" , "b1.in" , "b2.in" , "b3.in" , "c1.in" , "c2.in" , "c3.in" }},
453
- {description : "'rt bad' spec" , commandArgs : []string {"--spec=" + buildAddDepsRemoteSpec , "--from-rt" }, expectedDependencies : allFiles },
454
- {description : "'rt bad' two specFiles" , commandArgs : []string {"--spec=" + buildAddDepsDoubleRemoteSpec , "--from-rt" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" , "b1.in" , "b2.in" , "b3.in" }},
451
+ {description : "'rt bad' simple cli" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--from-rt" }, expectedDependencies : allFiles , expectedModule : tests .RtBuildName1 },
452
+ {description : "'rt bad' simple cli" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--from-rt" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : allFiles , expectedModule : ModuleNameJFrogTest },
453
+ {description : "'rt bad' single file" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/a1.in" , "--from-rt" }, expectedDependencies : []string {"a1.in" }, expectedModule : tests .RtBuildName1 },
454
+ {description : "'rt bad' none recursive" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--recursive=false" , "--from-rt" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" }, expectedModule : tests .RtBuildName1 },
455
+ {description : "'rt bad' exclude command line wildcards" , commandArgs : []string {tests .RtRepo1 + "/testdata/a/*" , "--exclusions=*a2*;*a3.in" , "--from-rt" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : []string {"a1.in" , "b1.in" , "b2.in" , "b3.in" , "c1.in" , "c2.in" , "c3.in" }, expectedModule : ModuleNameJFrogTest },
456
+ {description : "'rt bad' spec" , commandArgs : []string {"--spec=" + buildAddDepsRemoteSpec , "--from-rt" }, expectedDependencies : allFiles , expectedModule : tests .RtBuildName1 },
457
+ {description : "'rt bad' two specFiles" , commandArgs : []string {"--spec=" + buildAddDepsDoubleRemoteSpec , "--from-rt" }, expectedDependencies : []string {"a1.in" , "a2.in" , "a3.in" , "b1.in" , "b2.in" , "b3.in" }, expectedModule : tests .RtBuildName1 },
455
458
}
456
459
457
460
// Tests compatibility to file paths with windows separators.
458
461
if coreutils .IsWindows () {
459
462
var compatibilityTests = []buildAddDepsBuildInfoTestParams {
460
- {description : "'rt bad' win compatibility by arguments" , commandArgs : []string {"testdata\\ \\ a\\ \\ a1.in" }, expectedDependencies : []string {"a1.in" }},
461
- {description : "'rt bad' win compatibility by spec" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .WinBuildAddDepsSpec )}, expectedDependencies : allFiles },
463
+ {description : "'rt bad' win compatibility by arguments" , commandArgs : []string {"testdata\\ \\ a\\ \\ a1.in" }, expectedDependencies : []string {"a1.in" }, expectedModule : tests .RtBuildName1 },
464
+ {description : "'rt bad' win compatibility by arguments" , commandArgs : []string {"testdata\\ \\ a\\ \\ a1.in" , "--module=" + ModuleNameJFrogTest }, expectedDependencies : []string {"a1.in" }, expectedModule : ModuleNameJFrogTest },
465
+ {description : "'rt bad' win compatibility by spec" , commandArgs : []string {"--spec=" + tests .GetFilePathForArtifactory (tests .WinBuildAddDepsSpec )}, expectedDependencies : allFiles , expectedModule : tests .RtBuildName1 },
462
466
}
463
467
badTests = append (badTests , compatibilityTests ... )
464
468
}
@@ -881,6 +885,10 @@ func validateBuildAddDepsBuildInfo(t *testing.T, buildInfoTestParams buildAddDep
881
885
"%s test with the command: \n rt bad %s \n expected to have the following dependencies: \n %s \n but has: \n %s" ,
882
886
buildInfoTestParams .description , buildInfoTestParams .commandArgs , buildInfoTestParams .expectedDependencies , dependenciesToPrintableArray (buildInfo .Modules [0 ].Dependencies ))
883
887
888
+ assert .Equalf (t , buildInfoTestParams .expectedModule , buildInfo .Modules [0 ].Id ,
889
+ "%s test with the command: \n rt bad %s \n expected to have the following Module ID: \n %s \n but has: \n %s" ,
890
+ buildInfoTestParams .description , buildInfoTestParams .commandArgs , buildInfoTestParams .expectedModule , buildInfo .Modules [0 ].Id )
891
+
884
892
for _ , expectedDependency := range buildInfoTestParams .expectedDependencies {
885
893
found := false
886
894
for _ , actualDependency := range buildInfo .Modules [0 ].Dependencies {
@@ -909,4 +917,5 @@ type buildAddDepsBuildInfoTestParams struct {
909
917
expectedDependencies []string
910
918
buildName string
911
919
buildNumber string
920
+ expectedModule string
912
921
}
0 commit comments