Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

fix: exclude defaultSchemaLocations in offline k8s validation #643

Merged
merged 15 commits into from
May 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: add test case for getAllSchemaLocations offline
  • Loading branch information
royhadad committed May 24, 2022
commit 94d398ac7dda96295fe100e1c23beb66df92d1b5
13 changes: 11 additions & 2 deletions bl/validation/k8sValidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func TestValidateResources(t *testing.T) {
test_valid_multiple_configurations(t)
test_valid_multiple_configurations_only_k8s_files(t)
test_invalid_file(t)
test_get_all_schema_locations(t)
test_get_all_schema_locations_online(t)
test_get_all_schema_locations_offline(t)
test_get_datree_crd_schema_by_name(t)
t.Run("test empty file", test_empty_file)
t.Run("test no internet connection", test_no_connection)
Expand Down Expand Up @@ -210,7 +211,7 @@ func test_missing_schema_skipped(t *testing.T) {
assert.Equal(t, "k8s schema validation skipped: --ignore-missing-schemas flag was used", k8sValidationWarningPerValidFile[path].Warning)
}

func test_get_all_schema_locations(t *testing.T) {
func test_get_all_schema_locations_online(t *testing.T) {
expectedOutput := []string{
"/my-local-schema-location",
"default",
Expand All @@ -221,6 +222,14 @@ func test_get_all_schema_locations(t *testing.T) {
assert.Equal(t, expectedOutput, actual)
}

func test_get_all_schema_locations_offline(t *testing.T) {
expectedOutput := []string{
"/my-local-schema-location",
}
actual := getAllSchemaLocations([]string{"/my-local-schema-location"}, true)
assert.Equal(t, expectedOutput, actual)
}

func test_get_datree_crd_schema_by_name(t *testing.T) {
input := "argo"
expectedOutput := "https://raw.githubusercontent.com/datreeio/CRDs-catalog/master/argo/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json"
Expand Down