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

Bug 1952906: Add a few tests to configobserver_test.go #409

Merged
merged 3 commits into from
May 7, 2021
Merged
Changes from 1 commit
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
26 changes: 13 additions & 13 deletions pkg/config/configobserver/configobserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ import (
clienttesting "k8s.io/client-go/testing"
)

type kubeClientResponder struct {
clsetfake.Clientset
}

var _ kubernetes.Interface = (*kubeClientResponder)(nil)
0sewa0 marked this conversation as resolved.
Show resolved Hide resolved

const (
pullSecretKey = "(/v1, Resource=secrets) openshift-config.pull-secret" //nolint: gosec
supportKey = "(/v1, Resource=secrets) openshift-config.support"
)

//nolint: lll, funlen
func Test_ConfigObserver_ChangeSupportConfig(t *testing.T) {
var cases = []struct {
Expand Down Expand Up @@ -74,13 +85,13 @@ func Test_ConfigObserver_ChangeSupportConfig(t *testing.T) {
},
expConfig: &config.Controller{}, // it only produces a warning in the log
},
{name: "reportPullingDelay incorrect format",
{name: "reportPullingTimeout incorrect format",
config: map[string]*corev1.Secret{
pullSecretKey: {Data: map[string][]byte{
".dockerconfigjson": nil,
}},
supportKey: {Data: map[string][]byte{
"reportPullingDelay": []byte("every second"),
"reportPullingTimeout": []byte("every second"),
}},
},
expConfig: &config.Controller{}, // it only produces a warning in the log
Expand Down Expand Up @@ -236,11 +247,6 @@ func Test_ConfigObserver_ConfigChanged(t *testing.T) {
}
}
0sewa0 marked this conversation as resolved.
Show resolved Hide resolved

const (
pullSecretKey = "(/v1, Resource=secrets) openshift-config.pull-secret" //nolint: gosec
supportKey = "(/v1, Resource=secrets) openshift-config.support"
)

func provideSecretMock(kube kubernetes.Interface, secs map[string]*corev1.Secret) {
kube.CoreV1().(*corefake.FakeCoreV1).Fake.AddReactor("get", "secrets",
func(action clienttesting.Action) (handled bool, ret runtime.Object, err error) {
Expand All @@ -258,9 +264,3 @@ func provideSecretMock(kube kubernetes.Interface, secs map[string]*corev1.Secret
return true, sv, nil
})
}

type kubeClientResponder struct {
clsetfake.Clientset
}

var _ kubernetes.Interface = (*kubeClientResponder)(nil)