From ac05e38f15bdc7c9da5459629794a443bf166335 Mon Sep 17 00:00:00 2001 From: Ivo Meixner Date: Thu, 16 Apr 2020 16:52:12 +0200 Subject: [PATCH] Update content parser tests, improve coverage --- content/content_test.go | 7 ++++++ .../missing/external/rules/rule2/plugin.yaml | 13 ++++++++++ tests/content/no_external/config.yaml | 24 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/content/missing/external/rules/rule2/plugin.yaml create mode 100644 tests/content/no_external/config.yaml diff --git a/content/content_test.go b/content/content_test.go index 380c0f43..ea583ee8 100644 --- a/content/content_test.go +++ b/content/content_test.go @@ -89,3 +89,10 @@ func TestContentParseBadMetadataYAML(t *testing.T) { _, err := content.ParseRuleContentDir("../tests/content/bad_metadata/") assert.EqualError(t, err, errYAMLBadToken) } + +// TestContentParseBadMetadataYAML tests handling bad/incorrect metadata.yaml file +func TestContentParseNoExternal(t *testing.T) { + noExternalPath := "../tests/content/no_external" + _, err := content.ParseRuleContentDir(noExternalPath) + assert.EqualError(t, err, fmt.Sprintf("open %s/external: no such file or directory", noExternalPath)) +} diff --git a/tests/content/missing/external/rules/rule2/plugin.yaml b/tests/content/missing/external/rules/rule2/plugin.yaml new file mode 100644 index 00000000..f63cf9ca --- /dev/null +++ b/tests/content/missing/external/rules/rule2/plugin.yaml @@ -0,0 +1,13 @@ +# Copyright 2020 Red Hat, Inc +# +# 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. diff --git a/tests/content/no_external/config.yaml b/tests/content/no_external/config.yaml new file mode 100644 index 00000000..72df45ec --- /dev/null +++ b/tests/content/no_external/config.yaml @@ -0,0 +1,24 @@ +# Copyright 2020 Red Hat, Inc +# +# 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. + +impact: + One: 1 + Two: 2 + Three: 3 + Four: 4 + Five: 5 + Six: 6 + Seven: 7 + Eight: 8 + Nine: 9