From 7a27ae035eb75555b8e2fb7118ca1b9a34bd3ce4 Mon Sep 17 00:00:00 2001 From: Simar Date: Thu, 8 Aug 2024 15:23:54 -0600 Subject: [PATCH] fix unit test --- pkg/compliance/spec/compliance_test.go | 6 +++--- .../content/specs/compliance/testspec.yaml | 2 -- pkg/compliance/spec/testdata/testspec.yaml | 17 ----------------- 3 files changed, 3 insertions(+), 22 deletions(-) delete mode 100644 pkg/compliance/spec/testdata/testspec.yaml diff --git a/pkg/compliance/spec/compliance_test.go b/pkg/compliance/spec/compliance_test.go index 901d5db099c6..9ad5d56cd781 100644 --- a/pkg/compliance/spec/compliance_test.go +++ b/pkg/compliance/spec/compliance_test.go @@ -264,7 +264,7 @@ func TestComplianceSpec_CheckIDs(t *testing.T) { func TestComplianceSpec_LoadFromDiskBundle(t *testing.T) { t.Run("load user specified spec from disk", func(t *testing.T) { - cs, err := spec.GetComplianceSpec(filepath.Join("@testdata", "testspec.yaml"), cache.RealCache{}) + cs, err := spec.GetComplianceSpec(filepath.Join("@testdata", "testcache", "content", "specs", "compliance", "testspec.yaml"), cache.RealCache{}) require.NoError(t, err) assert.Equal(t, spec.ComplianceSpec{Spec: iacTypes.Spec{ ID: "test-spec-1.2", @@ -290,7 +290,7 @@ func TestComplianceSpec_LoadFromDiskBundle(t *testing.T) { t.Run("load user specified spec from disk fails", func(t *testing.T) { _, err := spec.GetComplianceSpec("@doesnotexist", cache.RealCache{}) - assert.Contains(t, err.Error(), "no such file or directory") + assert.Contains(t, err.Error(), "error retrieving compliance spec from specified path") }) t.Run("bundle does not exist", func(t *testing.T) { @@ -331,7 +331,7 @@ func TestComplianceSpec_LoadFromDiskBundle(t *testing.T) { return "does not exist" }, }) - assert.Contains(t, err.Error(), "no such file or directory") + assert.Contains(t, err.Error(), "error retrieving compliance spec from bundle testspec") }) // TODO: Add check to cover spec yaml unmarshal failure diff --git a/pkg/compliance/spec/testdata/testcache/content/specs/compliance/testspec.yaml b/pkg/compliance/spec/testdata/testcache/content/specs/compliance/testspec.yaml index beed9edbd51d..ec1f75f52970 100644 --- a/pkg/compliance/spec/testdata/testcache/content/specs/compliance/testspec.yaml +++ b/pkg/compliance/spec/testdata/testcache/content/specs/compliance/testspec.yaml @@ -3,8 +3,6 @@ spec: title: Test Spec description: This is a test spec version: "1.2" - platfrom: test - type: foo relatedResources: - https://www.google.ca controls: diff --git a/pkg/compliance/spec/testdata/testspec.yaml b/pkg/compliance/spec/testdata/testspec.yaml deleted file mode 100644 index beed9edbd51d..000000000000 --- a/pkg/compliance/spec/testdata/testspec.yaml +++ /dev/null @@ -1,17 +0,0 @@ -spec: - id: test-spec-1.2 - title: Test Spec - description: This is a test spec - version: "1.2" - platfrom: test - type: foo - relatedResources: - - https://www.google.ca - controls: - - id: "1.1" - name: moar-testing - description: |- - Test needs foo bar baz - checks: - - id: AVD-TEST-1234 - severity: LOW \ No newline at end of file