Skip to content

Commit

Permalink
pkg/versioncheck: Replace gocheck with built-in go test
Browse files Browse the repository at this point in the history
Signed-off-by: Tam Mach <tam.mach@cilium.io>
  • Loading branch information
sayboras committed Apr 28, 2024
1 parent 43abf65 commit 6cd5a39
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions pkg/versioncheck/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,13 @@
package versioncheck

import (
"fmt"
"testing"

. "github.com/cilium/checkmate"

"github.com/cilium/cilium/pkg/checker"
"github.com/stretchr/testify/require"
)

// Hook up gocheck into the "go test" runner.
func Test(t *testing.T) {
TestingT(t)
}

type VersionCheckTestSuite struct{}

var _ = Suite(&VersionCheckTestSuite{})

func (vc *VersionCheckTestSuite) TestMustCompile(c *C) {
func TestMustCompile(t *testing.T) {
tests := []struct {
version string
constraint string
Expand Down Expand Up @@ -117,11 +107,14 @@ func (vc *VersionCheckTestSuite) TestMustCompile(c *C) {
want: false,
},
}
for _, t := range tests {
ver, err := Version(t.version)
c.Assert(err, IsNil, Commentf("version %s, constraint %s", t.version, t.constraint))
constraint, err := Compile(t.constraint)
c.Assert(err, IsNil, Commentf("version %s, constraint", t.version, t.constraint))
c.Assert(constraint(ver), checker.Equals, t.want, Commentf("version %s, constraint %s", t.version, t.constraint))
for _, tt := range tests {
t.Run(tt.version, func(t *testing.T) {
ver, err := Version(tt.version)
require.NoError(t, err, fmt.Sprintf("version %s, constraint %s", tt.version, tt.constraint))

constraint, err := Compile(tt.constraint)
require.NoError(t, err, fmt.Sprintf("version %s, constraint %s", tt.version, tt.constraint))
require.Equal(t, tt.want, constraint(ver), fmt.Sprintf("version %s, constraint %s", tt.version, tt.constraint))
})
}
}

0 comments on commit 6cd5a39

Please sign in to comment.