|
7 | 7 | "github.com/openshift-kni/eco-goinfra/pkg/clients"
|
8 | 8 | "github.com/openshift-kni/eco-goinfra/pkg/schemes/kmm/v1beta1"
|
9 | 9 | "github.com/stretchr/testify/assert"
|
| 10 | + v1 "k8s.io/api/core/v1" |
10 | 11 | "k8s.io/apimachinery/pkg/api/errors"
|
11 | 12 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
12 | 13 | "k8s.io/apimachinery/pkg/runtime"
|
@@ -514,6 +515,62 @@ func TestModuleWithOptions(t *testing.T) {
|
514 | 515 | assert.Equal(t, "error", testBuilder.errorMsg)
|
515 | 516 | }
|
516 | 517 |
|
| 518 | +func TestModuleWithToleration(t *testing.T) { |
| 519 | + testCases := []struct { |
| 520 | + key string |
| 521 | + operator string |
| 522 | + value string |
| 523 | + effect string |
| 524 | + seconds int64 |
| 525 | + expectedErr string |
| 526 | + }{ |
| 527 | + { |
| 528 | + key: "", |
| 529 | + operator: "test", |
| 530 | + value: "test", |
| 531 | + effect: "test", |
| 532 | + seconds: 10, |
| 533 | + expectedErr: "cannot redefine with empty 'key' value", |
| 534 | + }, |
| 535 | + { |
| 536 | + key: "test", |
| 537 | + operator: "", |
| 538 | + value: "test", |
| 539 | + effect: "test", |
| 540 | + seconds: 10, |
| 541 | + expectedErr: "cannot redefine with empty 'operator' value", |
| 542 | + }, |
| 543 | + { |
| 544 | + key: "test", |
| 545 | + operator: "test", |
| 546 | + value: "test", |
| 547 | + effect: "", |
| 548 | + seconds: 10, |
| 549 | + expectedErr: "cannot redefine with empty 'effect' value", |
| 550 | + }, |
| 551 | + { |
| 552 | + key: "testkey", |
| 553 | + operator: "Equals", |
| 554 | + value: "testvalue", |
| 555 | + effect: "NoSchedule", |
| 556 | + seconds: 0, |
| 557 | + expectedErr: "", |
| 558 | + }, |
| 559 | + } |
| 560 | + for _, testCase := range testCases { |
| 561 | + testSettings := buildModuleTestClientWithDummyObject() |
| 562 | + testBuilder := buildValidTestModule(testSettings).WithToleration( |
| 563 | + testCase.key, testCase.operator, testCase.value, testCase.effect, testCase.seconds) |
| 564 | + |
| 565 | + if testCase.expectedErr == "" { |
| 566 | + assert.Equal(t, testCase.key, testBuilder.Definition.Spec.Tolerations[0].Key) |
| 567 | + assert.Equal(t, v1.TaintEffect(testCase.effect), testBuilder.Definition.Spec.Tolerations[0].Effect) |
| 568 | + } else { |
| 569 | + assert.Equal(t, testCase.expectedErr, testBuilder.errorMsg) |
| 570 | + } |
| 571 | + } |
| 572 | +} |
| 573 | + |
517 | 574 | func TestModuleBuildModuleSpec(t *testing.T) {
|
518 | 575 | testCases := []struct {
|
519 | 576 | testModule *ModuleBuilder
|
|
0 commit comments