Skip to content

Commit

Permalink
reuse maven testdata
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianburth committed May 28, 2024
1 parent 58e529c commit 6cec303
Show file tree
Hide file tree
Showing 74 changed files with 256 additions and 1,166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package maven_test

import (
"crypto"
"github.com/open-component-model/ocm/pkg/maven/maventest"

. "github.com/mandelsoft/goutils/testutils"
. "github.com/onsi/ginkgo/v2"
Expand All @@ -24,7 +25,7 @@ var _ = Describe("Test Environment", func() {
var env *TestEnv

BeforeEach(func() {
env = NewTestEnv(TestData())
env = NewTestEnv(TestData(), maventest.TestData("/maven/testdata"))

Expect(env.Execute("create", "ca", "-ft", "directory", "test.de/x", VERSION, "--provider", "mandelsoft", "--file", ARCH)).To(Succeed())
})
Expand Down Expand Up @@ -61,7 +62,7 @@ name: testdata
type: mavenArtifact
`
Expect(env.Execute("add", "resources", "--file", ARCH, "--resource", meta, "--inputType", "maven",
"--inputPath", "testdata/.m2/repository", "--groupId", "com.sap.cloud.sdk", "--artifactId", "sdk-modules-bom",
"--inputPath", "/maven/testdata/.m2/repository", "--groupId", "com.sap.cloud.sdk", "--artifactId", "sdk-modules-bom",
"--inputVersion", "5.7.0", "--classifier", "", "--extension", "pom")).To(Succeed())
data, err := env.ReadFile(env.Join(ARCH, comparch.ComponentDescriptorFileName))
Expect(err).To(Succeed())
Expand All @@ -80,7 +81,7 @@ name: testdata
type: mavenArtifact
`
Expect(env.Execute("add", "resources", "--file", ARCH, "--resource", meta, "--inputType", "maven",
"--inputPath", "testdata/.m2/repository", "--groupId", "com.sap.cloud.sdk", "--artifactId", "sdk-modules-bom",
"--inputPath", "/maven/testdata/.m2/repository", "--groupId", "com.sap.cloud.sdk", "--artifactId", "sdk-modules-bom",
"--inputVersion", "5.7.0", "--extension", "pom")).To(Succeed())
data, err := env.ReadFile(env.Join(ARCH, comparch.ComponentDescriptorFileName))
Expect(err).To(Succeed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: myblob
type: mavenArtifact
input:
type: maven
path: .m2/repository
path: ../maven/testdata/.m2/repository
groupId: com.sap.cloud.sdk
artifactId: sdk-modules-bom
version: 5.7.0
4 changes: 2 additions & 2 deletions pkg/blobaccess/maven/access_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package maven_test

import (
"github.com/open-component-model/ocm/pkg/maven/maventest"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/open-component-model/ocm/pkg/env"
. "github.com/open-component-model/ocm/pkg/env/builder"
. "github.com/open-component-model/ocm/pkg/testutils"

Expand All @@ -31,7 +31,7 @@ var _ = Describe("blobaccess for maven", func() {
var repo *maven.Repository

BeforeEach(func() {
env = NewBuilder(TestData())
env = NewBuilder(maventest.TestData())
repo = maven.NewFileRepository(MAVEN_PATH, env.FileSystem())
})

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 8 additions & 7 deletions pkg/contexts/ocm/accessmethods/maven/method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package maven_test

import (
"crypto"
"github.com/open-component-model/ocm/pkg/maven/maventest"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/open-component-model/ocm/pkg/env"
. "github.com/open-component-model/ocm/pkg/env/builder"
. "github.com/open-component-model/ocm/pkg/testutils"

Expand All @@ -20,7 +20,7 @@ import (

const (
MAVEN_PATH = "/testdata/.m2/repository"
FAILPATH = "/testdata/fail"
FAILPATH = "/testdata/.m2/fail"
MAVEN_CENTRAL = "https://repo.maven.apache.org/maven2/"
MAVEN_CENTRAL_ADDRESS = "repo.maven.apache.org:443"
MAVEN_GROUP_ID = "maven"
Expand All @@ -33,7 +33,7 @@ var _ = Describe("local accessmethods.maven.AccessSpec tests", func() {
var cv ocm.ComponentVersionAccess

BeforeEach(func() {
env = NewBuilder(TestData())
env = NewBuilder(maventest.TestData())
cv = &cpi.DummyComponentVersionAccess{env.OCMContext()}
})

Expand All @@ -56,8 +56,8 @@ var _ = Describe("local accessmethods.maven.AccessSpec tests", func() {
break
}
}
Expect(dr.Size()).To(Equal(int64(1109)))
Expect(dr.Digest().String()).To(Equal("SHA-1:4ee125ffe4f7690588833f1217a13cc741e4df5f"))
Expect(dr.Size()).To(Equal(int64(1570)))
Expect(dr.Digest().String()).To(Equal("SHA-1:359d02795bcc737e81c7f2f0ac32f49351d41867"))
})

It("accesses local artifact with empty classifier and with extension", func() {
Expand Down Expand Up @@ -90,14 +90,15 @@ var _ = Describe("local accessmethods.maven.AccessSpec tests", func() {
defer Close(r)
dr := iotools.NewDigestReaderWithHash(crypto.SHA1, r)
list := Must(tarutils.ListArchiveContentFromReader(dr))
Expect(list).To(HaveLen(1))
Expect(list).To(ConsistOf("sdk-modules-bom-5.7.0.pom"))

Expect(dr.Size()).To(Equal(int64(1109)))
Expect(dr.Digest().String()).To(Equal("SHA-1:4ee125ffe4f7690588833f1217a13cc741e4df5f"))
})

It("Describe", func() {
acc := me.New("file://"+FAILPATH, "test", "repository", "42", me.WithExtension("pom"))
Expect(acc.Describe(nil)).To(Equal("Maven package 'test:repository:42::pom' in repository 'file:///testdata/fail' path 'test/repository/42/repository-42.pom'"))
Expect(acc.Describe(nil)).To(Equal("Maven package 'test:repository:42::pom' in repository 'file:///testdata/.m2/fail' path 'test/repository/42/repository-42.pom'"))
})

It("detects digests mismatch", func() {
Expand Down
Loading

0 comments on commit 6cec303

Please sign in to comment.