github.com/elek/golangci-lint@v1.42.2-0.20211208090441-c05b7fcb3a9a/pkg/result/processors/processor_test.go (about)

     1  package processors
     2  
     3  import (
     4  	"go/token"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  
     9  	"github.com/elek/golangci-lint/pkg/result"
    10  )
    11  
    12  type issueTestCase struct {
    13  	Path     string
    14  	Line     int
    15  	Text     string
    16  	Linter   string
    17  	Severity string
    18  }
    19  
    20  func newIssueFromIssueTestCase(c issueTestCase) result.Issue {
    21  	return result.Issue{
    22  		Text:       c.Text,
    23  		FromLinter: c.Linter,
    24  		Pos: token.Position{
    25  			Filename: c.Path,
    26  			Line:     c.Line,
    27  		},
    28  	}
    29  }
    30  
    31  func newIssueFromTextTestCase(text string) result.Issue {
    32  	return result.Issue{
    33  		Text: text,
    34  	}
    35  }
    36  
    37  func process(t *testing.T, p Processor, issues ...result.Issue) []result.Issue {
    38  	processedIssues, err := p.Process(issues)
    39  	assert.NoError(t, err)
    40  	return processedIssues
    41  }
    42  
    43  func processAssertSame(t *testing.T, p Processor, issues ...result.Issue) {
    44  	processedIssues := process(t, p, issues...)
    45  	assert.Equal(t, issues, processedIssues)
    46  }
    47  
    48  func processAssertEmpty(t *testing.T, p Processor, issues ...result.Issue) {
    49  	processedIssues := process(t, p, issues...)
    50  	assert.Empty(t, processedIssues)
    51  }