Skip to content

Commit

Permalink
add negative test for non-semver version (#759)
Browse files Browse the repository at this point in the history
## Description

## What type of PR is this? (check all applicable)

- [ ] πŸ• Feature
- [ ] πŸŽ‡ Restructuring
- [ ] πŸ› Bug Fix
- [ ] πŸ“ Documentation Update
- [ ] 🎨 Style
- [ ] πŸ§‘β€πŸ’» Code Refactor
- [ ] πŸ”₯ Performance Improvements
- [x] βœ… Test
- [ ] πŸ€– Build
- [ ] πŸ” CI
- [ ] πŸ“¦ Chore (Release)
- [ ] ⏩ Revert

## Related Issues

- #758
- #756

## Added tests?

- [ ] πŸ‘ yes
- [ ] πŸ™… no, because they aren't needed
- [ ] πŸ™‹ no, because I need help
- [ ] Separate ticket for tests # (issue/pr)

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration


## Added to documentation?

- [ ] πŸ“œ README.md
- [ ] πŸ™… no documentation needed

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
  • Loading branch information
hilmarf authored May 2, 2024
1 parent ebe976e commit 0b2baf5
Showing 1 changed file with 12 additions and 8 deletions.
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

0 comments on commit 0b2baf5

Please sign in to comment.