From 74718efd82c54d190d1fa4f9ffeacebe987444f8 Mon Sep 17 00:00:00 2001 From: Ted Teng Date: Thu, 20 Oct 2022 14:47:16 +0800 Subject: [PATCH] fix make test --- pkg/cmd/info/info.go | 2 +- pkg/cmd/info/info_test.go | 4 +--- pkg/cmd/info/options.go | 15 +++++++-------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/cmd/info/info.go b/pkg/cmd/info/info.go index 54e1b39f..158c2c5e 100644 --- a/pkg/cmd/info/info.go +++ b/pkg/cmd/info/info.go @@ -14,7 +14,7 @@ import ( ) // NewCmdInfo returns a new info command. -func NewCmdInfo(f util.Factory, o *options) *cobra.Command { +func NewCmdInfo(f util.Factory, o *Options) *cobra.Command { cmd := &cobra.Command{ Use: "info", Short: "Get landscape informations and shows the number of shoots per seed, e.g. \"gardenctl info\"", diff --git a/pkg/cmd/info/info_test.go b/pkg/cmd/info/info_test.go index 1679a12e..ad7b2c1c 100644 --- a/pkg/cmd/info/info_test.go +++ b/pkg/cmd/info/info_test.go @@ -6,8 +6,6 @@ SPDX-License-Identifier: Apache-2.0 package info_test import ( - "fmt" - internalfake "github.com/gardener/gardenctl-v2/internal/fake" "github.com/gardener/gardenctl-v2/internal/util" cmdinfo "github.com/gardener/gardenctl-v2/pkg/cmd/info" @@ -110,7 +108,7 @@ var _ = Describe("Info Command", func() { cmd := cmdinfo.NewCmdInfo(factory, o) Expect(cmd.RunE(cmd, nil)).To(Succeed()) - Expect(out.String()).To(Equal(fmt.Sprintf("Garden: mygarden\nSeed Total Active Hibernated Allocatable Capacity\n---- ----- ------ ---------- ----------- --------\n---- ----- ------ ---------- ----------- --------\nTOTAL 3 2 0 - -\nUnscheduled 1\nUnscheduled List brokenShoot\n\n"))) + Expect(out.String()).To(Equal("Garden: mygarden\nSeed Total Active Hibernated Allocatable Capacity\n---- ----- ------ ---------- ----------- --------\n---- ----- ------ ---------- ----------- --------\nTOTAL 3 2 0 - -\nUnscheduled 1\nUnscheduled List brokenShoot\n\n")) }) }) }) diff --git a/pkg/cmd/info/options.go b/pkg/cmd/info/options.go index db8d1810..88d39c3f 100644 --- a/pkg/cmd/info/options.go +++ b/pkg/cmd/info/options.go @@ -17,8 +17,7 @@ import ( ) // InfoOptions is a struct to support Info command -// nolint -type options struct { +type Options struct { base.Options // Allocatable is the seed allocatable Allocatable int64 @@ -26,9 +25,9 @@ type options struct { Capacity int64 } -// NewInfoOptions returns initialized InfoOptions -func NewInfoOptions(ioStreams util.IOStreams) *options { - return &options{ +// NewInfoOptions returns initialized Options +func NewInfoOptions(ioStreams util.IOStreams) *Options { + return &Options{ Options: base.Options{ IOStreams: ioStreams, }, @@ -36,7 +35,7 @@ func NewInfoOptions(ioStreams util.IOStreams) *options { } // Run does the actual work of the command -func (o *options) Run(f util.Factory) error { +func (o *Options) Run(f util.Factory) error { manager, err := f.Manager() if err != nil { return err @@ -69,7 +68,7 @@ func (o *options) Run(f util.Factory) error { totalShootsCountPerSeed = make(map[string]int) hibernatedShootsCountPerSeed = make(map[string]int) unscheduledList = make([]string, 0) - infoOptions = make(map[string]options) + infoOptions = make(map[string]Options) valAllocatable int64 valCapacity int64 ) @@ -90,7 +89,7 @@ func (o *options) Run(f util.Factory) error { return fmt.Errorf("capacity conversion is not possible") } - infoOptions[seed.Name] = options{Allocatable: valAllocatable, Capacity: valCapacity} + infoOptions[seed.Name] = Options{Allocatable: valAllocatable, Capacity: valCapacity} } for _, shoot := range shootList.Items {