Skip to content

Commit

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

import (
"testing"

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

func TestFilterIssuesByStatus(t *testing.T) {
issues := &Issues{
Issues: []Issue{
{
Status: "OPEN",
},
{
Status: "CLOSED",
},
},
}

issues = issues.FilterByStatus("OPEN")
assert.Equal(t, 1, len(issues.Issues))
assert.Equal(t, "OPEN", issues.Issues[0].Status)
}

func TestFilterOutByTag(t *testing.T) {
issues := &Issues{
Issues: []Issue{
{
Message: "first issue",
Tags: []string{"first", "second"},
},
{
Message: "second issue",
Tags: []string{"first", "third"},
},
},
}

issues = issues.FilterOutByTag("third")
assert.Equal(t, 1, len(issues.Issues))
assert.Equal(t, "first issue", issues.Issues[0].Message)
}

0 comments on commit bd26024

Please sign in to comment.