From d0b60b81fc70387ea565079c18db79a637f75511 Mon Sep 17 00:00:00 2001 From: attiasas Date: Mon, 6 Nov 2023 11:12:02 +0200 Subject: [PATCH] Add tests for maven build timestamp --- go.mod | 2 +- go.sum | 4 ++-- gradle_test.go | 8 +++++++- maven_test.go | 16 +++++++++++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index d8a67f1d1..c6993a151 100644 --- a/go.mod +++ b/go.mod @@ -129,7 +129,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc +replace github.com/jfrog/build-info-go => github.com/attiasas/build-info-go v0.0.0-20231106084437-b2341b4e2c7c replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20231105094115-13b1588fc537 diff --git a/go.sum b/go.sum index 4c109a921..6f49219dd 100644 --- a/go.sum +++ b/go.sum @@ -69,6 +69,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/attiasas/build-info-go v0.0.0-20231106084437-b2341b4e2c7c h1:aWtJGvrv9yZP9GB9jnR7KMRGBKV0b51KCC1TeQ6B88w= +github.com/attiasas/build-info-go v0.0.0-20231106084437-b2341b4e2c7c/go.mod h1:ujJ8XQZMdT2tMkLSMJNyDd1pCY+duwHdjV+9or9FLIg= github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= @@ -237,8 +239,6 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOl github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jedib0t/go-pretty/v6 v6.4.8 h1:HiNzyMSEpsBaduKhmK+CwcpulEeBrTmxutz4oX/oWkg= github.com/jedib0t/go-pretty/v6 v6.4.8/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVfmHZu9n8rk2xs= -github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc h1:MFejgCB90z7nA/KP48lF1t04tYuXAAQc53cBaFd9zcw= -github.com/jfrog/build-info-go v1.8.9-0.20231031143744-13f94ab07bbc/go.mod h1:ujJ8XQZMdT2tMkLSMJNyDd1pCY+duwHdjV+9or9FLIg= github.com/jfrog/gofrog v1.3.1 h1:QqAwQXCVReT724uga1AYqG/ZyrNQ6f+iTxmzkb+YFQk= github.com/jfrog/gofrog v1.3.1/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYLipdsOFMY= diff --git a/gradle_test.go b/gradle_test.go index 773521091..d3fbdb30e 100644 --- a/gradle_test.go +++ b/gradle_test.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "path/filepath" "strings" @@ -8,6 +9,7 @@ import ( clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" + "github.com/jfrog/build-info-go/build" buildinfo "github.com/jfrog/build-info-go/entities" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/gradle" "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils" @@ -79,10 +81,14 @@ func TestGradleBuildWithServerID(t *testing.T) { runJfrogCli(t, "gradle", "clean artifactoryPublish", "-b"+buildGradlePath, "--build-name="+tests.GradleBuildName, "--build-number="+buildNumber) clientTestUtils.ChangeDirAndAssert(t, oldHomeDir) // Validate + service := build.NewBuildInfoService() + bld, err := service.GetOrCreateBuild(tests.GradleBuildName, buildNumber) + assert.NoError(t, err) + buildTimestamp := fmt.Sprintf("%d", bld.GetBuildTimestamp().UnixMilli()) searchSpec, err := tests.CreateSpec(tests.SearchAllGradle) assert.NoError(t, err) inttestutils.VerifyExistInArtifactory(tests.GetGradleDeployedArtifacts(), searchSpec, serverDetails, t) - verifyExistInArtifactoryByProps(tests.GetGradleDeployedArtifacts(), tests.GradleRepo+"/*", "build.name="+tests.GradleBuildName+";build.number="+buildNumber, t) + verifyExistInArtifactoryByProps(tests.GetGradleDeployedArtifacts(), tests.GradleRepo+"/*", "build.name="+tests.GradleBuildName+";build.number="+buildNumber+";build.timestamp="+buildTimestamp, t) assert.NoError(t, artifactoryCli.Exec("bp", tests.GradleBuildName, buildNumber)) publishedBuildInfo, found, err := tests.GetBuildInfo(serverDetails, tests.GradleBuildName, buildNumber) diff --git a/maven_test.go b/maven_test.go index 16311cb5c..23a75e8f5 100644 --- a/maven_test.go +++ b/maven_test.go @@ -2,6 +2,12 @@ package main import ( "fmt" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/jfrog/build-info-go/build" buildinfo "github.com/jfrog/build-info-go/entities" biutils "github.com/jfrog/build-info-go/utils" "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/mvn" @@ -17,10 +23,6 @@ import ( "github.com/jfrog/jfrog-client-go/utils/log" clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests" "github.com/stretchr/testify/assert" - "os" - "path/filepath" - "strings" - "testing" ) const mavenTestsProxyPort = "1028" @@ -206,10 +208,14 @@ func TestMavenBuildIncludePatterns(t *testing.T) { assert.NoError(t, runMaven(t, createMultiMavenProject, tests.MavenIncludeExcludePatternsConfig, "install", "--build-name="+tests.MvnBuildName, "--build-number="+buildNumber)) // Validate deployed artifacts. + service := build.NewBuildInfoService() + bld, err := service.GetOrCreateBuild(tests.MvnBuildName, buildNumber) + assert.NoError(t, err) + buildTimestamp := fmt.Sprintf("%d", bld.GetBuildTimestamp().UnixMilli()) searchSpec, err := tests.CreateSpec(tests.SearchAllMaven) assert.NoError(t, err) inttestutils.VerifyExistInArtifactory(tests.GetMavenMultiIncludedDeployedArtifacts(), searchSpec, serverDetails, t) - verifyExistInArtifactoryByProps(tests.GetMavenMultiIncludedDeployedArtifacts(), tests.MvnRepo1+"/*", "build.name="+tests.MvnBuildName+";build.number="+buildNumber, t) + verifyExistInArtifactoryByProps(tests.GetMavenMultiIncludedDeployedArtifacts(), tests.MvnRepo1+"/*", "build.name="+tests.MvnBuildName+";build.number="+buildNumber+";build.timestamp="+buildTimestamp, t) // Validate build info. assert.NoError(t, artifactoryCli.Exec("build-publish", tests.MvnBuildName, buildNumber))