Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
attiasas committed Sep 26, 2023
1 parent 954d9c9 commit 1d97508
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions xray/utils/sarifutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,37 @@ func TestGetRelativeLocationFileName(t *testing.T) {
}
}

func TestGetFullLocationFileName(t *testing.T) {
tests := []struct {
file string
invocations []*sarif.Invocation
expectedOutput string
}{
{
file: "root/someDir/another/file",
invocations: []*sarif.Invocation{},
expectedOutput: "root/someDir/another/file",
},
{
file: "/another/file",
invocations: []*sarif.Invocation{
{WorkingDirectory: sarif.NewSimpleArtifactLocation("/root/someDir/")},
{WorkingDirectory: sarif.NewSimpleArtifactLocation("/not/relevant")},
},
expectedOutput: "/root/someDir/another/file",
},
{
file: "another/file",
invocations: []*sarif.Invocation{{WorkingDirectory: sarif.NewSimpleArtifactLocation("/root/someDir")}},
expectedOutput: "/root/someDir/another/file",
},
}

for _, test := range tests {
assert.Equal(t, test.expectedOutput, GetFullLocationFileName(test.file, test.invocations))
}
}

func TestSetLocationFileName(t *testing.T) {
tests := []struct {
location *sarif.Location
Expand Down

0 comments on commit 1d97508

Please sign in to comment.