Skip to content

Commit

Permalink
Logger changed
Browse files Browse the repository at this point in the history
Signed-off-by: rcmadhankumar <[email protected]>
  • Loading branch information
rcmadhankumar committed Jan 17, 2024
1 parent 14e3c1a commit 9cb2cf4
Showing 1 changed file with 11 additions and 42 deletions.
53 changes: 11 additions & 42 deletions pkg/apiserver/registry/datapackaging/package_crd_rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
k8sfake "k8s.io/client-go/kubernetes/fake"
cgtesting "k8s.io/client-go/testing"
"k8s.io/klog/v2"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)

const globalNamespace = "global.packaging.kapp-controller.carvel.dev"
Expand All @@ -35,10 +33,7 @@ func TestPackageVersionListIncludesGlobalAndNamespaced(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalIntPackageVersion(), namespacedIntPackageVersion(), excludedNonGlobalIntPackageVersion())
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

pkgvList, err := pkgvCRDREST.List(namespacedCtx(nonGlobalNamespace), &internalversion.ListOptions{})
if err != nil {
Expand Down Expand Up @@ -73,10 +68,7 @@ func TestPackageVersionListPrefersNamespacedOverGlobal(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalIntPackageVersion(), overrideIntPackageVersion())
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

// list package versions and verify all of them are there
pkgvList, err := pkgvCRDREST.List(namespacedCtx(nonGlobalNamespace), &internalversion.ListOptions{})
Expand Down Expand Up @@ -111,10 +103,7 @@ func TestPackageVersionGetNotPresentInNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{})
if err != nil {
Expand All @@ -139,10 +128,7 @@ func TestPackageVersionGetPresentInOnlyNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(namespacedPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{})
if err != nil {
Expand All @@ -166,10 +152,8 @@ func TestPackageVersionGetNotFound(t *testing.T) {

internalClient := fake.NewSimpleClientset(namespacedPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())
log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)

pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

_, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{})
if err == nil {
Expand All @@ -188,10 +172,7 @@ func TestPackageVersionGetPreferNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(overridePackageVersion, globalIntPackageVersion())
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

obj, err := pkgvCRDREST.Get(namespacedCtx(nonGlobalNamespace), name, &metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -221,10 +202,7 @@ func TestPackageVersionUpdateDoesntUpdateGlobal(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalPackageVersion, namespacedPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

obj, created, err := pkgvCRDREST.Update(namespacedCtx(nonGlobalNamespace), name, UpdatePackageVersionTestImpl{updateReleaseNotesFn(newReleaseNotes, name, packageName, version)}, nil, nil, false, &metav1.UpdateOptions{})
if err != nil {
Expand Down Expand Up @@ -265,10 +243,7 @@ func TestPackageVersionUpdateCreatesInNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

obj, created, err := pkgvCRDREST.Update(namespacedCtx(nonGlobalNamespace), name, UpdatePackageVersionTestImpl{updateReleaseNotesFn(newReleaseNotes, name, packageName, version)}, nil, nil, false, &metav1.UpdateOptions{})
if err != nil {
Expand Down Expand Up @@ -302,10 +277,7 @@ func TestPackageVersionDeleteExistsInNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(namespacedPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

_, _, err := pkgvCRDREST.Delete(namespacedCtx(nonGlobalNamespace), name, nil, &metav1.DeleteOptions{})
if err != nil {
Expand Down Expand Up @@ -337,10 +309,7 @@ func TestPackageVersionDeleteExistsGlobalNotInNS(t *testing.T) {
internalClient := fake.NewSimpleClientset(globalPackageVersion)
fakeCoreClient := k8sfake.NewSimpleClientset(namespace())

log := zap.New(zap.UseDevMode(false)).WithName("package_crd_rest_test")
logf.SetLogger(log)
klog.SetLogger(log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, log)
pkgvCRDREST := datapkgreg.NewPackageCRDREST(internalClient, fakeCoreClient, globalNamespace, logf.Log)

_, _, err := pkgvCRDREST.Delete(namespacedCtx(nonGlobalNamespace), name, nil, &metav1.DeleteOptions{})
if !errors.IsNotFound(err) {
Expand Down

0 comments on commit 9cb2cf4

Please sign in to comment.