Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Mar 4, 2024
1 parent 4a04cf0 commit cff8ea3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/advisory/export_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
})
}
}

0 comments on commit cff8ea3

Please sign in to comment.