Skip to content

Commit

Permalink
test: make models tests their own package (#423)
Browse files Browse the repository at this point in the history
This reduces the diff with #183 a bit, and is good practice
  • Loading branch information
G-Rath committed Jun 27, 2023
1 parent d572130 commit d378b92
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions pkg/models/vulnerability_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package models
package models_test

import (
"encoding/json"
"testing"

"github.com/google/osv-scanner/pkg/models"
"gopkg.in/yaml.v3"
)

func TestAffected_MarshalJSONWithPackage(t *testing.T) {
t.Parallel()
v := Vulnerability{
v := models.Vulnerability{
ID: "TEST-0000",
Affected: []Affected{
Affected: []models.Affected{
{
Package: Package{Ecosystem: EcosystemPyPI, Name: "requests"},
Package: models.Package{Ecosystem: models.EcosystemPyPI, Name: "requests"},
Versions: []string{"1.0.0"},
},
},
Expand All @@ -30,9 +31,9 @@ func TestAffected_MarshalJSONWithPackage(t *testing.T) {

func TestAffected_MarshalJSONWithoutPackage(t *testing.T) {
t.Parallel()
v := Vulnerability{
v := models.Vulnerability{
ID: "TEST-0000",
Affected: []Affected{
Affected: []models.Affected{
{
Versions: []string{"1.0.0"},
},
Expand All @@ -50,11 +51,11 @@ func TestAffected_MarshalJSONWithoutPackage(t *testing.T) {

func TestAffected_MarshalYAMLWithPackage(t *testing.T) {
t.Parallel()
v := Vulnerability{
v := models.Vulnerability{
ID: "TEST-0000",
Affected: []Affected{
Affected: []models.Affected{
{
Package: Package{Ecosystem: EcosystemPyPI, Name: "requests"},
Package: models.Package{Ecosystem: models.EcosystemPyPI, Name: "requests"},
Versions: []string{"1.0.0"},
},
},
Expand All @@ -79,9 +80,9 @@ affected:

func TestAffected_MarshalYAMLWithoutPackage(t *testing.T) {
t.Parallel()
v := Vulnerability{
v := models.Vulnerability{
ID: "TEST-0000",
Affected: []Affected{
Affected: []models.Affected{
{
Versions: []string{"1.0.0"},
},
Expand Down

0 comments on commit d378b92

Please sign in to comment.