Skip to content

Commit

Permalink
added tests for sonarqube issue struct
Browse files Browse the repository at this point in the history
  • Loading branch information
herlon214 committed Dec 5, 2021
1 parent 015e064 commit ad9496e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/sonarqube/issue_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package sonarqube

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestMarkdownMessage(t *testing.T) {
issue := Issue{
Project: "myproject",
Component: "myproject:pkg/my_file.go",
Severity: "CRITICAL",
Type: "BUG",
Rule: "go:S1234",
Message: "My message",
}

assert.Equal(t, ":bug::bangbang: CRITICAL: My message ([go:S1234](https://my-sonar/coding_rules?open=go:S1234&rule_key=go:S1234))", issue.MarkdownMessage("https://my-sonar"))
}

func TestFilePath(t *testing.T) {
issue := Issue{Project: "myproject", Component: "myproject:pkg/file.go"}

assert.Equal(t, "pkg/file.go", issue.FilePath())
}

func TestTypeEmojis(t *testing.T) {
assert.Equal(t, ":bug:", Issue{Type: "BUG"}.TypeEmoji())
assert.Equal(t, ":biohazard:", Issue{Type: "CODE_SMELL"}.TypeEmoji())
assert.Equal(t, ":key:", Issue{Type: "VULNERABILITY"}.TypeEmoji())
assert.Equal(t, ":thought_balloon:", Issue{Type: "SOMETHINGELSE"}.TypeEmoji())

}

0 comments on commit ad9496e

Please sign in to comment.