github.com/samiam2013/sqlvet@v0.0.0-20221210043606-d72f678fc0aa/pkg/vet/comment_parser_test.go (about)

     1  package vet_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  
     8  	"github.com/samiam2013/sqlvet/pkg/vet"
     9  )
    10  
    11  func TestParseComment(t *testing.T) {
    12  	tcase := []string{
    13  		"sqlvet: ignore",
    14  		"   sqlvet:ignore",
    15  		" sqlvet: ignore",
    16  		"  sqlvet: ignore ",
    17  	}
    18  
    19  	for _, c := range tcase {
    20  		t.Run(c, func(t *testing.T) {
    21  			anno, err := vet.ParseComment(c)
    22  			assert.NoError(t, err)
    23  			assert.Equal(t, vet.SqlVetAnnotation{Ignore: true}, anno)
    24  		})
    25  	}
    26  }
    27  
    28  func TestParseCommentWithoutAnnotation(t *testing.T) {
    29  	tcase := []string{
    30  		"ssqlvet: ignore",
    31  		"   sqlvet:ok",
    32  		"sqlvet ignore",
    33  		"hello world!",
    34  	}
    35  
    36  	for _, c := range tcase {
    37  		t.Run(c, func(t *testing.T) {
    38  			_, err := vet.ParseComment(c)
    39  			assert.Error(t, err)
    40  		})
    41  	}
    42  }