Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add negative test for non-semver version #759

Merged
merged 4 commits into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pkg/contexts/ocm/repositories/genericocireg/repo_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// SPDX-FileCopyrightText: 2022 SAP SE or an SAP affiliate company and Open Component Model contributors.
//
// SPDX-License-Identifier: Apache-2.0

package genericocireg_test

import (
"fmt"
"path"
"reflect"

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

"github.com/mandelsoft/vfs/pkg/osfs"
"github.com/mandelsoft/vfs/pkg/vfs"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/opencontainers/go-digest"

"github.com/open-component-model/ocm/pkg/blobaccess"
Expand Down Expand Up @@ -50,6 +44,7 @@ import (
"github.com/open-component-model/ocm/pkg/finalizer"
"github.com/open-component-model/ocm/pkg/mime"
"github.com/open-component-model/ocm/pkg/signing/hasher/sha256"
. "github.com/open-component-model/ocm/pkg/testutils"
)

var DefaultContext = ocm.New()
Expand Down Expand Up @@ -79,6 +74,15 @@ var _ = Describe("component repository mapping", func() {
vfs.Cleanup(tempfs)
})

It("Don't Panik! When it's not a semver.org conform version. #756", func() {
repo := Must(DefaultContext.RepositoryForSpec(spec))
comp := Must(repo.LookupComponent(COMPONENT))
cva, err := comp.NewVersion("v1.two.zeo-2")
Expect(err).To(HaveOccurred())
Expect(cva).To(BeNil())
Expect(err.Error()).To(Equal("Invalid Semantic Version"))
})

It("creates a dummy component", func() {
var finalize finalizer.Finalizer
defer Defer(finalize.Finalize)
Expand Down
Loading