-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Valeriy Khorunzhin <valeriy.khorunzhin@flant.com>
- Loading branch information
Valeriy Khorunzhin
committed
Jan 14, 2025
1 parent
fdb767e
commit ea2db1c
Showing
3 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
images/virtualization-artifact/pkg/controller/vmclass/internal/discovery_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
Copyright 2024 Flant JSC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package internal | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
type nodeNamesDiffTestParams struct { | ||
prev []string | ||
current []string | ||
added []string | ||
removed []string | ||
} | ||
|
||
var _ = Describe("DiscoveryHandler Run", func() { | ||
DescribeTable( | ||
"NodeNamesDiffTest", | ||
func(params nodeNamesDiffTestParams) { | ||
calculatedAdded, calculatedRemoved := NodeNamesDiff(params.prev, params.current) | ||
Expect(calculatedAdded).Should(Equal(params.added)) | ||
Expect(calculatedRemoved).Should(Equal(params.removed)) | ||
}, | ||
Entry( | ||
"Should be no diff", | ||
nodeNamesDiffTestParams{ | ||
prev: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
current: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
added: []string{}, | ||
removed: []string{}, | ||
}, | ||
), | ||
Entry( | ||
"Should be added node", | ||
nodeNamesDiffTestParams{ | ||
prev: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
current: []string{ | ||
"node1", | ||
"node2", | ||
"node3", | ||
}, | ||
added: []string{ | ||
"node3", | ||
}, | ||
removed: []string{}, | ||
}, | ||
), | ||
Entry( | ||
"Should be removed node", | ||
nodeNamesDiffTestParams{ | ||
prev: []string{ | ||
"node1", | ||
"node2", | ||
"node3", | ||
}, | ||
current: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
added: []string{}, | ||
removed: []string{ | ||
"node3", | ||
}, | ||
}, | ||
), | ||
Entry( | ||
"Should be added and removed node", | ||
nodeNamesDiffTestParams{ | ||
prev: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
current: []string{ | ||
"node2", | ||
"node3", | ||
}, | ||
added: []string{ | ||
"node3", | ||
}, | ||
removed: []string{ | ||
"node1", | ||
}, | ||
}, | ||
), | ||
Entry( | ||
"Should be multiple added and removed node", | ||
nodeNamesDiffTestParams{ | ||
prev: []string{ | ||
"node3", | ||
"node4", | ||
"node5", | ||
}, | ||
current: []string{ | ||
"node1", | ||
"node2", | ||
"node3", | ||
}, | ||
added: []string{ | ||
"node1", | ||
"node2", | ||
}, | ||
removed: []string{ | ||
"node4", | ||
"node5", | ||
}, | ||
}, | ||
), | ||
) | ||
}) |
29 changes: 29 additions & 0 deletions
29
images/virtualization-artifact/pkg/controller/vmclass/internal/internal_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright 2024 Flant JSC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package internal | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestInternal(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Internal") | ||
} |