Skip to content

Commit

Permalink
test: add tests for AdvisoryID
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed May 15, 2024
1 parent 995ea97 commit 7074604
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions mariner/mariner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,69 @@ func TestUpdate(t *testing.T) {
})
}
}

func TestAdvisoryID(t *testing.T) {
tests := []struct {
name string
def mariner.Definition
want string
}{
{
name: "advisory_id without version",
def: mariner.Definition{
Metadata: mariner.Metadata{
AdvisoryID: "1111",
},
},
want: "1111",
},
{
name: "advisory_id with version",
def: mariner.Definition{
Metadata: mariner.Metadata{
AdvisoryID: "1111-2",
},
},
want: "1111-2",
},
{
name: "build advisoryID converting long version to 1",
def: mariner.Definition{
ID: "oval:com.microsoft.cbl-mariner:def:27423",
Version: "2000000001",
},
want: "27423-1",
},
{
name: "build advisoryID converting long version to 0",
def: mariner.Definition{
ID: "oval:com.microsoft.cbl-mariner:def:27423",
Version: "2000000000",
},
want: "27423",
},
{
name: "build advisoryID with short 1 version",
def: mariner.Definition{
ID: "oval:com.microsoft.cbl-mariner:def:27423",
Version: "1",
},
want: "27423-1",
},
{
name: "build advisoryID with short 0 version",
def: mariner.Definition{
ID: "oval:com.microsoft.cbl-mariner:def:27423",
Version: "0",
},
want: "27423",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := mariner.AdvisoryID(tt.def)
require.Equal(t, tt.want, got)
})
}
}

0 comments on commit 7074604

Please sign in to comment.