Skip to content

Commit

Permalink
refactor(sbom): remove context filepath for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Jul 2, 2024
1 parent 82c2620 commit e0b36ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions pkg/sbom/cyclonedx/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"

ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/log"
"github.com/aquasecurity/trivy/pkg/purl"
"github.com/aquasecurity/trivy/pkg/sbom/cyclonedx"
sbomio "github.com/aquasecurity/trivy/pkg/sbom/io"
Expand Down Expand Up @@ -759,8 +758,7 @@ func TestUnmarshaler_Unmarshal(t *testing.T) {
require.NoError(t, err)

var got types.SBOM
ctx := log.WithContextAttrs(context.Background(), log.String("filepath", tt.inputFile))
err = sbomio.NewDecoder(cdx.BOM).Decode(ctx, &got)
err = sbomio.NewDecoder(cdx.BOM).Decode(context.Background(), &got)
require.NoError(t, err)

got.BOM = nil
Expand Down
4 changes: 1 addition & 3 deletions pkg/sbom/spdx/unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/stretchr/testify/require"

ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/log"
sbomio "github.com/aquasecurity/trivy/pkg/sbom/io"
"github.com/aquasecurity/trivy/pkg/sbom/spdx"
"github.com/aquasecurity/trivy/pkg/types"
Expand Down Expand Up @@ -359,8 +358,7 @@ func TestUnmarshaler_Unmarshal(t *testing.T) {
}

var got types.SBOM
ctx := log.WithContextAttrs(context.Background(), log.String("filepath", tt.inputFile))
err = sbomio.NewDecoder(v.BOM).Decode(ctx, &got)
err = sbomio.NewDecoder(v.BOM).Decode(context.Background(), &got)
require.NoError(t, err)

// Not compare BOM
Expand Down

0 comments on commit e0b36ca

Please sign in to comment.