This repository has been archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore CRDs of skipped components (#1388)
* Ignore CRDs of skipped components * add test for env-var skip-comp logic * add logging * add correlation ID
- Loading branch information
Showing
4 changed files
with
81 additions
and
16 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
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
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
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,42 @@ | ||
package service | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/kyma-incubator/reconciler/pkg/logger" | ||
"github.com/kyma-incubator/reconciler/pkg/model" | ||
"github.com/kyma-incubator/reconciler/pkg/reconciler" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestInstall(t *testing.T) { | ||
tests := []struct { | ||
envVars map[string]string | ||
expected []string | ||
}{ | ||
{ | ||
envVars: map[string]string{ | ||
"IM_INVALID": "true", | ||
fmt.Sprintf("%s%s", model.SkippedComponentEnvVarPrefix, "ABC"): "tRue", | ||
fmt.Sprintf("%s%s", model.SkippedComponentEnvVarPrefix, "DE_F"): "1", | ||
fmt.Sprintf("%s%s", model.SkippedComponentEnvVarPrefix, "GH"): "0", | ||
fmt.Sprintf("%s%s", model.SkippedComponentEnvVarPrefix, "XYZ"): "truee", | ||
}, | ||
expected: []string{"abc", "de-f"}, | ||
}, | ||
} | ||
|
||
for _, testCase := range tests { | ||
install := NewInstall(logger.NewTestLogger(t)) | ||
for envKey, envValue := range testCase.envVars { | ||
os.Setenv(envKey, envValue) | ||
} | ||
got := install.skippedComps(&reconciler.Task{ | ||
CorrelationID: "unit-test-corrID", | ||
}) | ||
require.Len(t, got, len(testCase.expected)) | ||
require.ElementsMatch(t, testCase.expected, got) | ||
} | ||
} |