Skip to content

Commit

Permalink
Group check.v1 package with third-party package (kanisterio#3137)
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Bista <[email protected]>
  • Loading branch information
anishbista60 authored Sep 21, 2024
1 parent d207c41 commit abbb737
Show file tree
Hide file tree
Showing 136 changed files with 3,292 additions and 3,294 deletions.
42 changes: 21 additions & 21 deletions pkg/apis/cr/v1alpha1/repositoryserver_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"testing"

"github.com/pkg/errors"
. "gopkg.in/check.v1"
"gopkg.in/check.v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
)
Expand Down Expand Up @@ -58,28 +58,28 @@ spec:
username: test-kanister-user
`

func TestRepositoryServer(t *testing.T) { TestingT(t) }
func TestRepositoryServer(t *testing.T) { check.TestingT(t) }

func (s *TypesSuite) TestRepositoryServerDecode(c *C) {
func (s *TypesSuite) TestRepositoryServerDecode(c *check.C) {
rs, err := getRepositoryServerFromSpec([]byte(repoServerSpec))
c.Assert(err, IsNil)
c.Assert(rs, NotNil)
c.Assert(rs.Spec.Storage.SecretRef.Name, Equals, "test-s3-location")
c.Assert(rs.Spec.Storage.SecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Storage.CredentialSecretRef.Name, Equals, "test-s3-creds")
c.Assert(rs.Spec.Storage.CredentialSecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Repository.RootPath, Equals, "/test-repo-controller/")
c.Assert(rs.Spec.Repository.PasswordSecretRef.Name, Equals, "test-repo-pass")
c.Assert(rs.Spec.Repository.PasswordSecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Repository.Username, Equals, "test-repository-user")
c.Assert(rs.Spec.Repository.Hostname, Equals, "localhost")
c.Assert(rs.Spec.Server.AdminSecretRef.Name, Equals, "test-repository-admin-user")
c.Assert(rs.Spec.Server.AdminSecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Server.TLSSecretRef.Name, Equals, "test-repository-server-tls-cert")
c.Assert(rs.Spec.Server.TLSSecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Server.UserAccess.UserAccessSecretRef.Name, Equals, "test-repository-server-user-access")
c.Assert(rs.Spec.Server.UserAccess.UserAccessSecretRef.Namespace, Equals, "kanister")
c.Assert(rs.Spec.Server.UserAccess.Username, Equals, "test-kanister-user")
c.Assert(err, check.IsNil)
c.Assert(rs, check.NotNil)
c.Assert(rs.Spec.Storage.SecretRef.Name, check.Equals, "test-s3-location")
c.Assert(rs.Spec.Storage.SecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Storage.CredentialSecretRef.Name, check.Equals, "test-s3-creds")
c.Assert(rs.Spec.Storage.CredentialSecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Repository.RootPath, check.Equals, "/test-repo-controller/")
c.Assert(rs.Spec.Repository.PasswordSecretRef.Name, check.Equals, "test-repo-pass")
c.Assert(rs.Spec.Repository.PasswordSecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Repository.Username, check.Equals, "test-repository-user")
c.Assert(rs.Spec.Repository.Hostname, check.Equals, "localhost")
c.Assert(rs.Spec.Server.AdminSecretRef.Name, check.Equals, "test-repository-admin-user")
c.Assert(rs.Spec.Server.AdminSecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Server.TLSSecretRef.Name, check.Equals, "test-repository-server-tls-cert")
c.Assert(rs.Spec.Server.TLSSecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Server.UserAccess.UserAccessSecretRef.Name, check.Equals, "test-repository-server-user-access")
c.Assert(rs.Spec.Server.UserAccess.UserAccessSecretRef.Namespace, check.Equals, "kanister")
c.Assert(rs.Spec.Server.UserAccess.Username, check.Equals, "test-kanister-user")
}

func getRepositoryServerFromSpec(spec []byte) (*RepositoryServer, error) {
Expand Down
16 changes: 8 additions & 8 deletions pkg/apis/cr/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ import (
"testing"

"github.com/pkg/errors"
. "gopkg.in/check.v1"
"gopkg.in/check.v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
)

func Test(t *testing.T) { TestingT(t) }
func Test(t *testing.T) { check.TestingT(t) }

type TypesSuite struct{}

var _ = Suite(&TypesSuite{})
var _ = check.Suite(&TypesSuite{})

const bpSpec = `
actions:
Expand All @@ -50,7 +50,7 @@ actions:
foo: bar
`

func (s *TypesSuite) TestBlueprintDecode(c *C) {
func (s *TypesSuite) TestBlueprintDecode(c *check.C) {
expected := map[string]reflect.Kind{
"testint": reflect.Int64,
"teststring": reflect.String,
Expand All @@ -59,12 +59,12 @@ func (s *TypesSuite) TestBlueprintDecode(c *C) {
}

bp, err := getBlueprintFromSpec([]byte(bpSpec))
c.Assert(err, IsNil)
c.Assert(bp.Actions["echo"].Phases[0].Args, HasLen, len(expected))
c.Assert(err, check.IsNil)
c.Assert(bp.Actions["echo"].Phases[0].Args, check.HasLen, len(expected))
for n, evk := range expected {
v := bp.Actions["echo"].Phases[0].Args[n]
c.Check(v, Not(Equals), nil)
c.Check(reflect.TypeOf(v).Kind(), Equals, evk)
c.Check(v, check.Not(check.Equals), nil)
c.Check(reflect.TypeOf(v).Kind(), check.Equals, evk)
}
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/app/bp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ import (
"strings"
"testing"

. "gopkg.in/check.v1"
"gopkg.in/check.v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

crv1alpha1 "github.com/kanisterio/kanister/pkg/apis/cr/v1alpha1"
"github.com/kanisterio/kanister/pkg/function"
)

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

type BlueprintSuite struct{}

var _ = Suite(&BlueprintSuite{})
var _ = check.Suite(&BlueprintSuite{})

func (bs *BlueprintSuite) TestUpdateImageTags(c *C) {
func (bs *BlueprintSuite) TestUpdateImageTags(c *check.C) {
for _, bp := range []*crv1alpha1.Blueprint{
// BP with no phase with image arg
{
Expand Down Expand Up @@ -138,7 +138,7 @@ func (bs *BlueprintSuite) TestUpdateImageTags(c *C) {
}
}

func validateImageTags(c *C, bp *crv1alpha1.Blueprint) {
func validateImageTags(c *check.C, bp *crv1alpha1.Blueprint) {
podOverride := crv1alpha1.JSONMap{
"containers": []map[string]interface{}{
{
Expand All @@ -156,9 +156,9 @@ func validateImageTags(c *C, bp *crv1alpha1.Blueprint) {
// Verify if image with prefix "ghcr.io/kanisterio" is tagged "v9.99.9-dev"
c.Log(fmt.Sprintf("phase:%s, image:%s", phase.Name, image.(string)))
if strings.HasPrefix(image.(string), imagePrefix) {
c.Assert(strings.Split(image.(string), ":")[1], Equals, "v9.99.9-dev")
c.Assert(strings.Split(image.(string), ":")[1], check.Equals, "v9.99.9-dev")
}
c.Assert(phase.Args["podOverride"], DeepEquals, podOverride)
c.Assert(phase.Args["podOverride"], check.DeepEquals, podOverride)
}
}
}
44 changes: 22 additions & 22 deletions pkg/blockstorage/awsebs/awsebs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
. "gopkg.in/check.v1"
"gopkg.in/check.v1"

kaws "github.com/kanisterio/kanister/pkg/aws"
"github.com/kanisterio/kanister/pkg/blockstorage"
envconfig "github.com/kanisterio/kanister/pkg/config"
)

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

type AWSEBSSuite struct{}

var _ = Suite(&AWSEBSSuite{})
var _ = check.Suite(&AWSEBSSuite{})

func (s AWSEBSSuite) TestVolumeParse(c *C) {
func (s AWSEBSSuite) TestVolumeParse(c *check.C) {
expected := blockstorage.Volume{
Az: "the-availability-zone",
CreationTime: blockstorage.TimeStamp(time.Date(2008, 8, 21, 5, 50, 0, 0, time.UTC)),
Expand Down Expand Up @@ -71,20 +71,20 @@ func (s AWSEBSSuite) TestVolumeParse(c *C) {
VolumeType: aws.String("the-volume-type"),
})

c.Assert(volume, Not(IsNil))
c.Check(volume.Az, Equals, expected.Az)
c.Check(volume.CreationTime, Equals, expected.CreationTime)
c.Check(volume.Encrypted, Equals, expected.Encrypted)
c.Check(volume.ID, Equals, expected.ID)
c.Check(volume.Iops, Equals, expected.Iops)
c.Check(volume.SizeInBytes, Equals, expected.SizeInBytes)
c.Check(volume.Tags, DeepEquals, expected.Tags)
c.Check(volume.Type, Equals, blockstorage.TypeEBS)
c.Check(volume.VolumeType, Equals, expected.VolumeType)
c.Check(volume.Attributes, DeepEquals, expected.Attributes)
c.Assert(volume, check.Not(check.IsNil))
c.Check(volume.Az, check.Equals, expected.Az)
c.Check(volume.CreationTime, check.Equals, expected.CreationTime)
c.Check(volume.Encrypted, check.Equals, expected.Encrypted)
c.Check(volume.ID, check.Equals, expected.ID)
c.Check(volume.Iops, check.Equals, expected.Iops)
c.Check(volume.SizeInBytes, check.Equals, expected.SizeInBytes)
c.Check(volume.Tags, check.DeepEquals, expected.Tags)
c.Check(volume.Type, check.Equals, blockstorage.TypeEBS)
c.Check(volume.VolumeType, check.Equals, expected.VolumeType)
c.Check(volume.Attributes, check.DeepEquals, expected.Attributes)
}

func (s AWSEBSSuite) TestGetRegions(c *C) {
func (s AWSEBSSuite) TestGetRegions(c *check.C) {
ctx := context.Background()
config := map[string]string{}

Expand All @@ -94,18 +94,18 @@ func (s AWSEBSSuite) TestGetRegions(c *C) {
// create provider with region
config[kaws.ConfigRegion] = "us-west-2"
bsp, err := NewProvider(ctx, config)
c.Assert(err, IsNil)
c.Assert(err, check.IsNil)
ebsp := bsp.(*EbsStorage)

// get zones with other region
zones, err := ebsp.FromRegion(ctx, "us-east-1")
c.Assert(err, IsNil)
c.Assert(err, check.IsNil)
for _, zone := range zones {
c.Assert(strings.Contains(zone, "us-east-1"), Equals, true)
c.Assert(strings.Contains(zone, "us-west-2"), Equals, false)
c.Assert(strings.Contains(zone, "us-east-1"), check.Equals, true)
c.Assert(strings.Contains(zone, "us-west-2"), check.Equals, false)
}

regions, err := ebsp.GetRegions(ctx)
c.Assert(err, IsNil)
c.Assert(regions, NotNil)
c.Assert(err, check.IsNil)
c.Assert(regions, check.IsNil)
}
8 changes: 4 additions & 4 deletions pkg/blockstorage/awsebs/zone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
package awsebs

import (
. "gopkg.in/check.v1"
"gopkg.in/check.v1"

"github.com/kanisterio/kanister/pkg/blockstorage/zone"
)

type ZoneSuite struct{}

var _ = Suite(&ZoneSuite{})
var _ = check.Suite(&ZoneSuite{})

func (s ZoneSuite) TestZoneWithUnknownNodeZones(c *C) {
func (s ZoneSuite) TestZoneWithUnknownNodeZones(c *check.C) {
defaultZones := []string{"us-west-2a", "us-west-2b", "us-west-2c"}
for _, tc := range []struct {
zones []string
Expand All @@ -48,6 +48,6 @@ func (s ZoneSuite) TestZoneWithUnknownNodeZones(c *C) {
},
} {
z := zone.SanitizeAvailableZones(tc.in, tc.zones)
c.Assert(z, DeepEquals, tc.out)
c.Assert(z, check.DeepEquals, tc.out)
}
}
Loading

0 comments on commit abbb737

Please sign in to comment.