Skip to content

Commit

Permalink
fixed sarif unit tests hardcoding code smell (#857)
Browse files Browse the repository at this point in the history
  • Loading branch information
Devang Gaur authored Jun 11, 2021
1 parent e43bd0f commit 617ef74
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions pkg/writer/sarif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ package writer

import (
"bytes"
"fmt"
"strings"
"testing"

"github.com/accurics/terrascan/pkg/policy"
"github.com/accurics/terrascan/pkg/results"
"github.com/accurics/terrascan/pkg/utils"
"github.com/accurics/terrascan/pkg/version"
)

const expectedSarifOutput1 = `{
var expectedSarifOutput1 = fmt.Sprintf(`{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
"driver": {
"name": "terrascan",
"version": "1.7.0",
"version": "%s",
"informationUri": "https://github.com/accurics/terrascan",
"rules": [
{
Expand Down Expand Up @@ -64,34 +66,34 @@ const expectedSarifOutput1 = `{
]
}
]
}`
}`, version.GetNumeric())

const expectedSarifOutput2 = `{
var expectedSarifOutput2 = fmt.Sprintf(`{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
"driver": {
"name": "terrascan",
"version": "1.7.0",
"version": "%s",
"informationUri": "https://github.com/accurics/terrascan"
}
},
"results": []
}
]
}`
}`, version.GetNumeric())

const expectedSarifOutput3 = `{
var expectedSarifOutput3 = fmt.Sprintf(`{
"version": "2.1.0",
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"runs": [
{
"tool": {
"driver": {
"name": "terrascan",
"version": "1.7.0",
"version": "%s",
"informationUri": "https://github.com/accurics/terrascan",
"rules": [
{
Expand All @@ -111,7 +113,7 @@ const expectedSarifOutput3 = `{
"results": []
}
]
}`
}`, version.GetNumeric())

func TestSarifWriter(t *testing.T) {

Expand Down

0 comments on commit 617ef74

Please sign in to comment.