Skip to content

Commit

Permalink
Merge branch 'master' into go-version-file-common
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykazakov authored Jul 16, 2024
2 parents 64e9f0d + 3789520 commit 9937dcf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
11 changes: 5 additions & 6 deletions controllers/toolchaincluster/toolchaincluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"sigs.k8s.io/controller-runtime/pkg/client"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -61,7 +60,7 @@ func TestClusterControllerChecks(t *testing.T) {
recresult, err := controller.Reconcile(context.TODO(), req)

// then
require.Equal(t, err, nil)
require.NoError(t, err)
require.Equal(t, reconcile.Result{Requeue: false, RequeueAfter: 0}, recresult)
})

Expand Down Expand Up @@ -101,7 +100,7 @@ func TestClusterControllerChecks(t *testing.T) {
recresult, err := controller.Reconcile(context.TODO(), req)

// then
require.Equal(t, err, nil)
require.NoError(t, err)
require.Equal(t, reconcile.Result{RequeueAfter: requeAfter}, recresult)
assertClusterStatus(t, cl, "stable", healthy())
})
Expand Down Expand Up @@ -138,7 +137,7 @@ func TestClusterControllerChecks(t *testing.T) {
// when
_, err := controller.Reconcile(context.TODO(), req)
secretAfterReconcile := &corev1.Secret{}
require.NoError(t, cl.Get(context.TODO(), client.ObjectKeyFromObject(secret), secretAfterReconcile))
require.NoError(t, cl.Get(context.TODO(), runtimeclient.ObjectKeyFromObject(secret), secretAfterReconcile))
actualKubeConfig, loadErr := clientcmd.Load(secretAfterReconcile.Data["kubeconfig"])

// then
Expand Down Expand Up @@ -174,10 +173,10 @@ func TestComposeKubeConfig(t *testing.T) {
}

func setupCachedClusters(t *testing.T, cl *test.FakeClient, clusters ...*toolchainv1alpha1.ToolchainCluster) func() {
service := cluster.NewToolchainClusterServiceWithClient(cl, logf.Log, test.MemberOperatorNs, 0, func(config *rest.Config, options client.Options) (client.Client, error) {
service := cluster.NewToolchainClusterServiceWithClient(cl, logf.Log, test.MemberOperatorNs, 0, func(config *rest.Config, options runtimeclient.Options) (runtimeclient.Client, error) {
// make sure that insecure is false to make Gock mocking working properly
config.Insecure = false
return client.New(config, options)
return runtimeclient.New(config, options)
})
for _, clustr := range clusters {
err := service.AddOrUpdateToolchainCluster(clustr)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type ToolchainClusterService struct {

type NewClient func(config *rest.Config, options client.Options) (client.Client, error)

// NewToolchainClusterServiceWithClient creates a new instance of ToolchainClusterService object and assigns the given newClient functione to be used for creating a client
// NewToolchainClusterServiceWithClient creates a new instance of ToolchainClusterService object and assigns the given newClient function to be used for creating a client
func NewToolchainClusterServiceWithClient(client client.Client, log logr.Logger, namespace string, timeout time.Duration, newClient NewClient) ToolchainClusterService {
service := NewToolchainClusterService(client, log, namespace, timeout)
service.newClient = newClient
Expand Down
15 changes: 7 additions & 8 deletions pkg/condition/condition_blackbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
apiv1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -522,7 +521,7 @@ func conditions(size int, prefix string) []toolchainv1alpha1.Condition {
conditions[i] = toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.ConditionType(fmt.Sprintf("%sTestConditionType%d", prefix, i)),
Message: fmt.Sprintf("%s Message %d", prefix, i),
Status: apiv1.ConditionTrue,
Status: corev1.ConditionTrue,
Reason: fmt.Sprintf("%sReason%d", prefix, i),
}
if prefix == "Existing" {
Expand All @@ -532,14 +531,14 @@ func conditions(size int, prefix string) []toolchainv1alpha1.Condition {
return conditions
}

func reverseStatus(status apiv1.ConditionStatus) apiv1.ConditionStatus {
func reverseStatus(status corev1.ConditionStatus) corev1.ConditionStatus {
switch status {
case apiv1.ConditionTrue, apiv1.ConditionUnknown:
return apiv1.ConditionFalse
case apiv1.ConditionFalse:
return apiv1.ConditionTrue
case corev1.ConditionTrue, corev1.ConditionUnknown:
return corev1.ConditionFalse
case corev1.ConditionFalse:
return corev1.ConditionTrue
default:
// Unknown
return apiv1.ConditionFalse
return corev1.ConditionFalse
}
}
5 changes: 3 additions & 2 deletions pkg/template/nstemplatetiers/nstemplatetier_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"context"
"embed"
"fmt"
"github.com/google/uuid"
"io/fs"
"path/filepath"
"regexp"
"testing"
texttemplate "text/template"

"github.com/google/uuid"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
commonclient "github.com/codeready-toolchain/toolchain-common/pkg/client"
"github.com/codeready-toolchain/toolchain-common/pkg/test"
Expand Down Expand Up @@ -616,7 +617,7 @@ func TestLoadTemplatesByTiers(t *testing.T) {
_, err := loadTemplatesByTiers(dummyMetadata, dummyTemplates)
// then
require.Error(t, err)
assert.EqualError(t, err, "unable to load templates: invalid name format for file '.DS_Store'")
require.EqualError(t, err, "unable to load templates: invalid name format for file '.DS_Store'")
})

t.Run("invalid filename scope", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/test/assertions/assertions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestExplain(t *testing.T) {
expl := Explain(pred, actual)

// then
assert.Equal(t, expl, "predicate 'assertions.predicateWithoutFixing' didn't match the object")
assert.Equal(t, "predicate 'assertions.predicateWithoutFixing' didn't match the object", expl)
})
}

Expand Down

0 comments on commit 9937dcf

Please sign in to comment.