Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make models tests their own package #423

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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