github.com/ldez/golangci-lint@v1.10.1/pkg/result/processors/autogenerated_exclude_test.go (about)

     1  package processors
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestIsAutogeneratedDetection(t *testing.T) {
    11  	all := `
    12  	// generated by stringer -type Pill pill.go; DO NOT EDIT
    13  
    14  // Code generated by "stringer -type Pill pill.go"; DO NOT EDIT
    15  
    16  // Code generated by vfsgen; DO NOT EDIT
    17  
    18  // Created by cgo -godefs - DO NOT EDIT
    19  
    20  /* Created by cgo - DO NOT EDIT. */
    21  
    22  // Generated by stringer -i a.out.go -o anames.go -p ppc64
    23  // Do not edit.
    24  
    25  // DO NOT EDIT
    26  // generated by: x86map -fmt=decoder ../x86.csv
    27  
    28  // DO NOT EDIT.
    29  // Generate with: go run gen.go -full -output md5block.go
    30  
    31  // generated by "go run gen.go". DO NOT EDIT.
    32  
    33  // DO NOT EDIT. This file is generated by mksyntaxgo from the RE2 distribution.
    34  
    35  // GENERATED BY make_perl_groups.pl; DO NOT EDIT.
    36  
    37  // generated by mknacl.sh - do not edit
    38  
    39  // DO NOT EDIT ** This file was generated with the bake tool ** DO NOT EDIT //
    40  
    41  // Generated by running
    42  //  maketables --tables=all --data=http://www.unicode.org/Public/8.0.0/ucd/UnicodeData.txt
    43  // --casefolding=http://www.unicode.org/Public/8.0.0/ucd/CaseFolding.txt
    44  // DO NOT EDIT
    45  
    46  /*
    47  * CODE GENERATED AUTOMATICALLY WITH github.com/ernesto-jimenez/gogen/unmarshalmap
    48  * THIS FILE SHOULD NOT BE EDITED BY HAND
    49  */
    50  
    51  // AUTOGENERATED FILE: easyjson file.go
    52  `
    53  
    54  	generatedCases := strings.Split(all, "\n\n")
    55  	for _, gc := range generatedCases {
    56  		isGenerated := isGeneratedFileByComment(gc)
    57  		assert.True(t, isGenerated)
    58  	}
    59  
    60  	notGeneratedCases := []string{"code not generated by", "test"}
    61  	for _, ngc := range notGeneratedCases {
    62  		isGenerated := isGeneratedFileByComment(ngc)
    63  		assert.False(t, isGenerated)
    64  	}
    65  }