@@ -11,6 +11,7 @@ func Test_NoMultilineComments(t *testing.T) {
1111 tests := []struct {
1212 Name string
1313 Content string
14+ Config string
1415 Expected helper.Issues
1516 }{
1617 {
@@ -23,7 +24,7 @@ This is a multiline comment
2324 Expected : helper.Issues {
2425 {
2526 Rule : NewNoMultilineCommentsRule (),
26- Message : "Multiline comments are not allowed, use single-line comment" ,
27+ Message : "Multiline comments are not allowed. Replace the comment with single-line comment(s) " ,
2728 Range : hcl.Range {
2829 Filename : "resource.tf" ,
2930 Start : hcl.Pos {Line : 2 , Column : 1 },
@@ -32,6 +33,44 @@ This is a multiline comment
3233 },
3334 },
3435 },
36+ {
37+ Name : "ProperMultilineAllowed" ,
38+ Content : `
39+ /*
40+ This is a multiline comment
41+ */
42+ ` ,
43+ Config : `
44+ rule "no_multiline_comments" {
45+ enabled = true
46+
47+ single_line_only = true
48+ }
49+ ` ,
50+ Expected : helper.Issues {},
51+ },
52+ {
53+ Name : "SingleLineMultiline" ,
54+ Content : `/* This isn't really a multiline comment */` ,
55+ Config : `
56+ rule "no_multiline_comments" {
57+ enabled = true
58+
59+ single_line_only = true
60+ }
61+ ` ,
62+ Expected : helper.Issues {
63+ {
64+ Rule : NewNoMultilineCommentsRule (),
65+ Message : "Using multiline comment syntax for single-line comments is not allowed. Use `#` instead." ,
66+ Range : hcl.Range {
67+ Filename : "resource.tf" ,
68+ Start : hcl.Pos {Line : 1 , Column : 1 },
69+ End : hcl.Pos {Line : 1 , Column : 44 },
70+ },
71+ },
72+ },
73+ },
3574 {
3675 Name : "SingleLine" ,
3776 Content : `//` ,
@@ -48,7 +87,7 @@ This is a multiline comment
4887
4988 for _ , test := range tests {
5089 t .Run (test .Name , func (t * testing.T ) {
51- runner := helper .TestRunner (t , map [string ]string {"resource.tf" : test .Content })
90+ runner := helper .TestRunner (t , map [string ]string {"resource.tf" : test .Content , ".tflint.hcl" : test . Config })
5291
5392 if err := rule .Check (runner ); err != nil {
5493 t .Fatalf ("Unexpected error occurred: %s" , err )
0 commit comments