Skip to content

Commit 6f21a2b

Browse files
committed
refactor
Signed-off-by: Pavel Tishkov <[email protected]>
1 parent 612fc1c commit 6f21a2b

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

images/hooks/cmd/discovery-virthandler-nodes/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const (
3939
virtHandlerNodeCountPath = "virtualization.internal.virtHandler.nodeCount"
4040
)
4141

42-
var _ = registry.RegisterFunc(configDiscoveryService, handleDiscoveryVirtHandkerNodes)
42+
var _ = registry.RegisterFunc(configDiscoveryService, handleDiscoveryVirtHandlerNodes)
4343

4444
var configDiscoveryService = &pkg.HookConfig{
4545
OnBeforeHelm: &pkg.OrderedConfig{Order: 5},
@@ -61,7 +61,7 @@ var configDiscoveryService = &pkg.HookConfig{
6161
Queue: fmt.Sprintf("modules/%s", common.MODULE_NAME),
6262
}
6363

64-
func handleDiscoveryVirtHandkerNodes(_ context.Context, input *pkg.HookInput) error {
64+
func handleDiscoveryVirtHandlerNodes(_ context.Context, input *pkg.HookInput) error {
6565
nodeCount := len(input.Snapshots.Get(nodesSnapshot))
6666
input.Values.Set(virtHandlerNodeCountPath, nodeCount)
6767
return nil

images/hooks/cmd/discovery-virthandler-nodes/main_test.go

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"bytes"
2120
"context"
22-
"os"
2321
"testing"
24-
"time"
2522

26-
"github.com/deckhouse/deckhouse/pkg/log"
2723
"github.com/deckhouse/module-sdk/pkg"
2824
"github.com/deckhouse/module-sdk/testing/mock"
29-
. "github.com/onsi/ginkgo"
25+
. "github.com/onsi/ginkgo/v2"
3026
. "github.com/onsi/gomega"
3127
)
3228

@@ -36,37 +32,19 @@ func TestDiscoveryVirthandlerNodes(t *testing.T) {
3632
}
3733

3834
var _ = Describe("Discovery virt-handler nodes", func() {
39-
err := os.Setenv("D8_IS_TESTS_ENVIRONMENT", "true")
40-
Expect(err).ShouldNot(HaveOccurred())
41-
4235
var (
43-
snapshots *mock.SnapshotsMock
44-
values *mock.PatchableValuesCollectorMock
45-
patchCollector *mock.PatchCollectorMock
46-
input *pkg.HookInput
47-
buf *bytes.Buffer
36+
snapshots *mock.SnapshotsMock
37+
values *mock.PatchableValuesCollectorMock
38+
input *pkg.HookInput
4839
)
4940

5041
BeforeEach(func() {
5142
snapshots = mock.NewSnapshotsMock(GinkgoT())
5243
values = mock.NewPatchableValuesCollectorMock(GinkgoT())
53-
patchCollector = mock.NewPatchCollectorMock(GinkgoT())
54-
55-
buf = bytes.NewBuffer([]byte{})
5644

5745
input = &pkg.HookInput{
5846
Values: values,
5947
Snapshots: snapshots,
60-
Logger: log.NewLogger(log.Options{
61-
Level: log.LevelDebug.Level(),
62-
Output: buf,
63-
TimeFunc: func(_ time.Time) time.Time {
64-
parsedTime, err := time.Parse(time.DateTime, "2006-01-02 15:04:05")
65-
Expect(err).ShouldNot(HaveOccurred())
66-
return parsedTime
67-
},
68-
}),
69-
PatchCollector: patchCollector,
7048
}
7149
})
7250

@@ -76,7 +54,7 @@ var _ = Describe("Discovery virt-handler nodes", func() {
7654
[]pkg.Snapshot{},
7755
)
7856
values.SetMock.When(virtHandlerNodeCountPath, 0)
79-
err := handleDiscoveryVirtHandkerNodes(context.Background(), input)
57+
err := handleDiscoveryVirtHandlerNodes(context.Background(), input)
8058
Expect(err).ShouldNot(HaveOccurred())
8159
})
8260
})
@@ -92,7 +70,7 @@ var _ = Describe("Discovery virt-handler nodes", func() {
9270
)
9371

9472
values.SetMock.When(virtHandlerNodeCountPath, 2)
95-
err := handleDiscoveryVirtHandkerNodes(context.Background(), input)
73+
err := handleDiscoveryVirtHandlerNodes(context.Background(), input)
9674
Expect(err).ShouldNot(HaveOccurred())
9775
})
9876
})

0 commit comments

Comments
 (0)