github.com/zmap/zlint@v1.1.0/zlint_test.go (about)

     1  package zlint
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  
     7  	"github.com/zmap/zlint/lints"
     8  )
     9  
    10  func TestLintNames(t *testing.T) {
    11  	allowedPrefixes := []string{
    12  		"n_", // lints.Notice
    13  		"w_", // lints.Warn
    14  		"e_", // lints.Error
    15  	}
    16  
    17  	for name := range lints.Lints {
    18  		var valid bool
    19  		for _, prefix := range allowedPrefixes {
    20  			if strings.HasPrefix(name, prefix) {
    21  				valid = true
    22  				break
    23  			}
    24  		}
    25  		if !valid {
    26  			t.Errorf("lint name %q does not start with an allowed prefix (%v)\n",
    27  				name, allowedPrefixes)
    28  		}
    29  	}
    30  }