Skip to content

Commit e8f36eb

Browse files
committed
adding test cases
1 parent 751c068 commit e8f36eb

3 files changed

Lines changed: 22 additions & 57 deletions

File tree

gradle_test.go

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ func TestGradleBuildWithServerID(t *testing.T) {
135135
return
136136
}
137137
buildInfo := publishedBuildInfo.BuildInfo
138-
validateBuildInfo(buildInfo, t, 0, 1, gradleModuleId, buildinfo.Gradle)
138+
// Expect 1 dependency (junit:4.7) since the project has source code using JUnit
139+
validateBuildInfo(buildInfo, t, 1, 1, gradleModuleId, buildinfo.Gradle)
139140
cleanGradleTest(t)
140141
}
141142

@@ -184,7 +185,8 @@ func TestGradleBuildWithServerIDAndDetailedSummary(t *testing.T) {
184185
return
185186
}
186187
buildInfo := publishedBuildInfo.BuildInfo
187-
validateBuildInfo(buildInfo, t, 0, 1, gradleModuleId, buildinfo.Gradle)
188+
// Expect 1 dependency (junit:4.7) since the project has source code using JUnit
189+
validateBuildInfo(buildInfo, t, 1, 1, gradleModuleId, buildinfo.Gradle)
188190
cleanGradleTest(t)
189191
}
190192

@@ -436,61 +438,6 @@ func TestGradleBuildWithFlexPackFullValidation(t *testing.T) {
436438
cleanGradleTest(t)
437439
}
438440

439-
// TestGradleBuildWithFlexPackProjectWithPlugin tests FlexPack with the projectwithplugin test project
440-
// This is the native equivalent of TestGradleBuildWithServerIDWithUsesPlugin but runs in FlexPack mode
441-
func TestGradleBuildWithFlexPackProjectWithPlugin(t *testing.T) {
442-
initGradleTest(t)
443-
444-
// Check if Gradle is available in the environment
445-
if _, err := exec.LookPath("gradle"); err != nil {
446-
t.Skip("Gradle not found in PATH, skipping Gradle FlexPack projectwithplugin test")
447-
}
448-
449-
// Create gradle project with plugin configuration
450-
buildGradlePath := createGradleProject(t, "projectwithplugin")
451-
oldHomeDir := changeWD(t, filepath.Dir(buildGradlePath))
452-
defer clientTestUtils.ChangeDirAndAssert(t, oldHomeDir)
453-
454-
buildName := tests.GradleBuildName + "-flexpack-plugin"
455-
buildNumber := "1"
456-
457-
// Set environment for native FlexPack implementation
458-
setEnvCallBack := clientTestUtils.SetEnvWithCallbackAndAssert(t, "JFROG_RUN_NATIVE", "true")
459-
defer setEnvCallBack()
460-
461-
// Windows compatibility
462-
buildGradlePath = strings.ReplaceAll(buildGradlePath, `\`, "/")
463-
464-
// Run gradle build (FlexPack mode - no config file, plugin is ignored in native mode)
465-
err := runJfrogCliWithoutAssertion("gradle", "clean", "build", "-b"+buildGradlePath, "--build-name="+buildName, "--build-number="+buildNumber)
466-
assert.NoError(t, err)
467-
468-
// Publish build info
469-
assert.NoError(t, artifactoryCli.Exec("bp", buildName, buildNumber))
470-
471-
// Validate build info was created
472-
publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, buildName, buildNumber)
473-
if err != nil {
474-
assert.NoError(t, err)
475-
return
476-
}
477-
if !found {
478-
assert.True(t, found, "build info was expected to be found")
479-
return
480-
}
481-
482-
// Validate build info structure
483-
buildInfo := publishedBuildInfo.BuildInfo
484-
assert.NotEmpty(t, buildInfo.Modules, "Build info should have modules")
485-
if len(buildInfo.Modules) > 0 {
486-
module := buildInfo.Modules[0]
487-
assert.Equal(t, buildinfo.Gradle, module.Type, "Module type should be Gradle")
488-
assert.NotEmpty(t, module.Id, "Module should have ID")
489-
}
490-
491-
cleanGradleTest(t)
492-
}
493-
494441
// TestGradleBuildWithFlexPackMultipleTasks tests FlexPack with multiple Gradle tasks
495442
// Similar to how traditional tests run "clean artifactoryPublish"
496443
func TestGradleBuildWithFlexPackMultipleTasks(t *testing.T) {

testdata/gradle/gradleproject/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
apply plugin: 'groovy'
22
apply plugin: 'idea'
33

4+
repositories {
5+
mavenCentral()
6+
}
7+
48
dependencies {
59
implementation "junit:junit:4.7"
610
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package example;
2+
3+
import org.junit.Assert;
4+
5+
/**
6+
* Simple example class that uses JUnit to ensure the dependency is resolved.
7+
*/
8+
public class Example {
9+
public boolean isTrue() {
10+
Assert.assertTrue(true);
11+
return true;
12+
}
13+
}
14+

0 commit comments

Comments
 (0)