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

remove double import #149

Closed
Closed
Show file tree
Hide file tree
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
60 changes: 27 additions & 33 deletions test/utils/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,23 @@ import (
"testing"
"time"

"github.com/kyma-project/eventing-manager/pkg/subscriptionmanager"
"github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/manager"
submanagermocks "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/manager/mocks"

apiclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"

subscriptionmanagermocks "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/mocks"
"github.com/stretchr/testify/mock"

corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"

"github.com/kyma-project/eventing-manager/test"

"github.com/avast/retry-go/v3"
"github.com/go-logr/zapr"
natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/testutils"
"github.com/onsi/gomega"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
admissionv1 "k8s.io/api/admissionregistration/v1"
v1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand All @@ -40,22 +38,18 @@ import (
"sigs.k8s.io/controller-runtime/pkg/envtest"

"github.com/kyma-project/eventing-manager/api/v1alpha1"
eventingv1alpha1 "github.com/kyma-project/eventing-manager/api/v1alpha1"
eventingctrl "github.com/kyma-project/eventing-manager/internal/controller/eventing"
"github.com/kyma-project/eventing-manager/options"
"github.com/kyma-project/eventing-manager/pkg/env"
"github.com/kyma-project/eventing-manager/pkg/eventing"
"github.com/kyma-project/eventing-manager/pkg/k8s"
"github.com/kyma-project/eventing-manager/pkg/logger"
"github.com/kyma-project/eventing-manager/pkg/subscriptionmanager"
"github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/manager"
submanagermocks "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/manager/mocks"
subscriptionmanagermocks "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/mocks"
"github.com/kyma-project/eventing-manager/test"
evnttestutils "github.com/kyma-project/eventing-manager/test/utils"
natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/testutils"
admissionv1 "k8s.io/api/admissionregistration/v1"
v1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
)

const (
Expand Down Expand Up @@ -90,7 +84,7 @@ type TestEnvironment struct {

//nolint:funlen // Used in testing
func NewTestEnvironment(projectRootDir string, celValidationEnabled bool,
allowedEventingCR *eventingv1alpha1.Eventing) (*TestEnvironment, error) {
allowedEventingCR *v1alpha1.Eventing) (*TestEnvironment, error) {
var err error
// setup context
ctx := context.Background()
Expand All @@ -114,7 +108,7 @@ func NewTestEnvironment(projectRootDir string, celValidationEnabled bool,
}

// add Eventing CRD scheme
err = eventingv1alpha1.AddToScheme(scheme.Scheme)
err = v1alpha1.AddToScheme(scheme.Scheme)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -354,8 +348,8 @@ func (env TestEnvironment) TearDown() error {

// GetEventingAssert fetches Eventing from k8s and allows making assertions on it.
func (env TestEnvironment) GetEventingAssert(g *gomega.GomegaWithT,
eventing *eventingv1alpha1.Eventing) gomega.AsyncAssertion {
return g.Eventually(func() *eventingv1alpha1.Eventing {
eventing *v1alpha1.Eventing) gomega.AsyncAssertion {
return g.Eventually(func() *v1alpha1.Eventing {
gotEventing, err := env.GetEventingFromK8s(eventing.Name, eventing.Namespace)
if err != nil {
log.Printf("fetch eventing %s/%s failed: %v", eventing.Name, eventing.Namespace, err)
Expand Down Expand Up @@ -533,7 +527,7 @@ func (env TestEnvironment) EnsureHPANotFound(t *testing.T, name, namespace strin
}

func (env TestEnvironment) EnsureEventingResourceDeletion(t *testing.T, name, namespace string) {
eventing := &eventingv1alpha1.Eventing{
eventing := &v1alpha1.Eventing{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -547,7 +541,7 @@ func (env TestEnvironment) EnsureEventingResourceDeletion(t *testing.T, name, na
}

func (env TestEnvironment) EnsureEventingResourceDeletionStateError(t *testing.T, name, namespace string) {
eventing := &eventingv1alpha1.Eventing{
eventing := &v1alpha1.Eventing{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand All @@ -556,7 +550,7 @@ func (env TestEnvironment) EnsureEventingResourceDeletionStateError(t *testing.T
env.EnsureK8sResourceDeleted(t, eventing)
require.Eventually(t, func() bool {
err := env.k8sClient.Get(env.Context, types.NamespacedName{Name: name, Namespace: namespace}, eventing)
return err == nil && eventing.Status.State == eventingv1alpha1.StateError
return err == nil && eventing.Status.State == v1alpha1.StateError
}, SmallTimeOut, SmallPollingInterval, "failed to ensure deletion of Eventing")
}

Expand Down Expand Up @@ -918,8 +912,8 @@ func getTestBackendConfig() env.BackendConfig {
}
}

func (env TestEnvironment) GetEventingFromK8s(name, namespace string) (*eventingv1alpha1.Eventing, error) {
eventing := &eventingv1alpha1.Eventing{}
func (env TestEnvironment) GetEventingFromK8s(name, namespace string) (*v1alpha1.Eventing, error) {
eventing := &v1alpha1.Eventing{}
err := env.k8sClient.Get(env.Context, types.NamespacedName{
Name: name,
Namespace: namespace,
Expand All @@ -928,7 +922,7 @@ func (env TestEnvironment) GetEventingFromK8s(name, namespace string) (*eventing
}

func (env TestEnvironment) DeleteEventingFromK8s(name, namespace string) error {
cr := &eventingv1alpha1.Eventing{
cr := &v1alpha1.Eventing{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Expand Down
7 changes: 3 additions & 4 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import (
"reflect"
"time"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"

appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kyma-project/eventing-manager/api/v1alpha1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
Expand Down