github.com/vanstinator/golangci-lint@v0.0.0-20240223191551-cc572f00d9d1/pkg/result/processors/exclude_test.go (about)

     1  package processors
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/vanstinator/golangci-lint/pkg/result"
     9  )
    10  
    11  func TestExclude(t *testing.T) {
    12  	p := NewExclude("^exclude$")
    13  	texts := []string{"excLude", "1", "", "exclud", "notexclude"}
    14  	var issues []result.Issue
    15  	for _, t := range texts {
    16  		issues = append(issues, newIssueFromTextTestCase(t))
    17  	}
    18  
    19  	processedIssues := process(t, p, issues...)
    20  	assert.Len(t, processedIssues, len(issues)-1)
    21  
    22  	var processedTexts []string
    23  	for _, i := range processedIssues {
    24  		processedTexts = append(processedTexts, i.Text)
    25  	}
    26  	assert.Equal(t, texts[1:], processedTexts)
    27  }
    28  
    29  func TestNoExclude(t *testing.T) {
    30  	processAssertSame(t, NewExclude(""), newIssueFromTextTestCase("test"))
    31  }
    32  
    33  func TestExcludeCaseSensitive(t *testing.T) {
    34  	p := NewExcludeCaseSensitive("^exclude$")
    35  	texts := []string{"excLude", "1", "", "exclud", "exclude"}
    36  	var issues []result.Issue
    37  	for _, t := range texts {
    38  		issues = append(issues, newIssueFromTextTestCase(t))
    39  	}
    40  
    41  	processedIssues := process(t, p, issues...)
    42  	assert.Len(t, processedIssues, len(issues)-1)
    43  
    44  	var processedTexts []string
    45  	for _, i := range processedIssues {
    46  		processedTexts = append(processedTexts, i.Text)
    47  	}
    48  	assert.Equal(t, texts[:len(texts)-1], processedTexts)
    49  }