From cff8ea344fc1af3e57efde270bcaf89312562b8b Mon Sep 17 00:00:00 2001 From: cpanato Date: Mon, 4 Mar 2024 12:41:47 -0500 Subject: [PATCH] add test --- pkg/advisory/export_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/advisory/export_test.go b/pkg/advisory/export_test.go index fa48c924..e7f7ab82 100644 --- a/pkg/advisory/export_test.go +++ b/pkg/advisory/export_test.go @@ -9,6 +9,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/wolfi-dev/wolfictl/pkg/configs" v2 "github.com/wolfi-dev/wolfictl/pkg/configs/advisory/v2" rwos "github.com/wolfi-dev/wolfictl/pkg/configs/rwfs/os" @@ -62,3 +63,31 @@ func Test_ExportFuncs(t *testing.T) { }) } } + +func TestImportAdvisoriesYAML(t *testing.T) { + const testdataDir = "./testdata/export/advisories" + + cases := []struct { + name string + pathToInputData string + }{ + { + name: "test-yaml", + pathToInputData: "./testdata/export/expected.yaml", + }, + } + + for _, tt := range cases { + t.Run(tt.name, func(t *testing.T) { + advisoryFsys := rwos.DirFS(testdataDir) + advisoryDocs, err := v2.NewIndex(context.Background(), advisoryFsys) + require.NoError(t, err) + + tempDir, importedDocuments, err := ImporAdvisoriesYAML(tt.pathToInputData) + require.NoError(t, err) + require.Equal(t, advisoryDocs.Select().Len(), importedDocuments.Select().Len()) + + defer os.RemoveAll(tempDir) + }) + } +}