diff options
author | 2020-10-30 17:06:04 +0100 | |
---|---|---|
committer | 2020-11-05 13:53:05 +0100 | |
commit | 5fe9e1b7c43fc1a34b38899a2a055540cc30ac81 (patch) | |
tree | 5a83d0219fa03f0d280db61ed44f64d377a04138 /certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go | |
parent | 15446c2ccfc117a0feb5a5249c2e62714b2cd3d7 (diff) |
[OOM-K8S-CERT-EXTERNAL-PROVIDER] Change logger implementation provider
Issue-ID: OOM-2559
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Change-Id: I717dfcfd74a01ccb81b2eb03c52be2c90fc3a9c5
Diffstat (limited to 'certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go')
-rw-r--r-- | certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go b/certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go index f4cb6944..cc3ba9f5 100644 --- a/certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go +++ b/certServiceK8sExternalProvider/src/cmpv2controller/cmpv2_issuer_controller_test.go @@ -23,17 +23,15 @@ package cmpv2controller import ( "testing" - "github.com/go-logr/logr" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "k8s.io/client-go/tools/record" "k8s.io/utils/clock" - ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api" provisioners "onap.org/oom-certservice/k8s-external-provider/src/cmpv2provisioner" + "onap.org/oom-certservice/k8s-external-provider/src/leveledlogger" "onap.org/oom-certservice/k8s-external-provider/src/testdata" ) @@ -60,13 +58,13 @@ func Test_shouldPrepareAndVerifyCMPv2Issuer_whenRequestReceived(t *testing.T) { func Test_shouldBeValidCMPv2IssuerSpec_whenAllFieldsAreSet(t *testing.T) { spec := testdata.GetValidCMPv2IssuerSpec() - err := validateCMPv2IssuerSpec(spec, &MockLogger{}) + err := validateCMPv2IssuerSpec(spec) assert.Nil(t, err) } func Test_shouldBeInvalidCMPv2IssuerSpec_whenSpecIsEmpty(t *testing.T) { spec := cmpv2api.CMPv2IssuerSpec{} - err := validateCMPv2IssuerSpec(spec, nil) + err := validateCMPv2IssuerSpec(spec) assert.NotNil(t, err) } @@ -90,13 +88,13 @@ func Test_shouldBeInvalidCMPv2IssuerSpec_whenNotAllFieldsAreSet(t *testing.T) { func test_shouldBeInvalidCMPv2IssuerSpec_whenFunctionApplied(t *testing.T, transformSpec func(spec *cmpv2api.CMPv2IssuerSpec)) { spec := testdata.GetValidCMPv2IssuerSpec() transformSpec(&spec) - err := validateCMPv2IssuerSpec(spec, nil) + err := validateCMPv2IssuerSpec(spec) assert.NotNil(t, err) } func getCMPv2IssuerController(fakeRecorder *record.FakeRecorder, mockClient client.Client) CMPv2IssuerController { controller := CMPv2IssuerController{ - Log: ctrl.Log.WithName("controllers").WithName("CertificateRequest"), + Log: leveledlogger.GetLoggerWithValues("controllers", "CMPv2Issuer"), Clock: clock.RealClock{}, Recorder: fakeRecorder, Client: mockClient, @@ -104,14 +102,3 @@ func getCMPv2IssuerController(fakeRecorder *record.FakeRecorder, mockClient clie } return controller } - -type MockLogger struct { - mock.Mock -} - -func (m *MockLogger) Info(msg string, keysAndValues ...interface{}) {} -func (m *MockLogger) Error(err error, msg string, keysAndValues ...interface{}) {} -func (m *MockLogger) Enabled() bool { return false } -func (m *MockLogger) V(level int) logr.Logger { return m } -func (m *MockLogger) WithValues(keysAndValues ...interface{}) logr.Logger { return m } -func (m *MockLogger) WithName(name string) logr.Logger { return m } |