@@ -92,6 +92,14 @@ func TestApplyConfig(t *testing.T) {
9292 "terraform_deprecated_interpolation" ,
9393 },
9494 },
95+ {
96+ name : "only" ,
97+ global : & tflint.Config {Only : []string {"terraform_deprecated_interpolation" }},
98+ config : & hclext.BodyContent {},
99+ want : []string {
100+ "terraform_deprecated_interpolation" ,
101+ },
102+ },
95103 {
96104 name : "disabled by default + preset" ,
97105 global : & tflint.Config {DisabledByDefault : true },
@@ -121,6 +129,17 @@ func TestApplyConfig(t *testing.T) {
121129 "terraform_comment_syntax" ,
122130 },
123131 },
132+ {
133+ name : "disabled by default + only" ,
134+ global : & tflint.Config {
135+ DisabledByDefault : true ,
136+ Only : []string {"terraform_comment_syntax" },
137+ },
138+ config : & hclext.BodyContent {},
139+ want : []string {
140+ "terraform_comment_syntax" ,
141+ },
142+ },
124143 {
125144 name : "preset + rule config" ,
126145 global : & tflint.Config {
@@ -140,6 +159,37 @@ func TestApplyConfig(t *testing.T) {
140159 "terraform_deprecated_index" ,
141160 },
142161 },
162+ {
163+ name : "preset + only" ,
164+ global : & tflint.Config {
165+ Only : []string {"terraform_deprecated_interpolation" },
166+ },
167+ config : & hclext.BodyContent {
168+ Attributes : hclext.Attributes {
169+ "preset" : & hclext.Attribute {Name : "preset" , Expr : mustParseExpr (`"recommended"` )},
170+ },
171+ },
172+ want : []string {
173+ "terraform_deprecated_interpolation" ,
174+ },
175+ },
176+ {
177+ name : "rule config + only" ,
178+ global : & tflint.Config {
179+ Rules : map [string ]* tflint.RuleConfig {
180+ "terraform_comment_syntax" : {
181+ Name : "terraform_comment_syntax" ,
182+ Enabled : false ,
183+ },
184+ },
185+ Only : []string {"terraform_comment_syntax" , "terraform_deprecated_interpolation" },
186+ },
187+ config : & hclext.BodyContent {},
188+ want : []string {
189+ "terraform_comment_syntax" ,
190+ "terraform_deprecated_interpolation" ,
191+ },
192+ },
143193 {
144194 name : "disabled by default + preset + rule config" ,
145195 global : & tflint.Config {
@@ -160,6 +210,28 @@ func TestApplyConfig(t *testing.T) {
160210 "terraform_deprecated_index" ,
161211 },
162212 },
213+ {
214+ name : "disabled by default + preset + rule config + only" ,
215+ global : & tflint.Config {
216+ Rules : map [string ]* tflint.RuleConfig {
217+ "terraform_comment_syntax" : {
218+ Name : "terraform_comment_syntax" ,
219+ Enabled : false ,
220+ },
221+ },
222+ DisabledByDefault : true ,
223+ Only : []string {"terraform_comment_syntax" , "terraform_deprecated_interpolation" },
224+ },
225+ config : & hclext.BodyContent {
226+ Attributes : hclext.Attributes {
227+ "preset" : & hclext.Attribute {Name : "preset" , Expr : mustParseExpr (`"recommended"` )},
228+ },
229+ },
230+ want : []string {
231+ "terraform_comment_syntax" ,
232+ "terraform_deprecated_interpolation" ,
233+ },
234+ },
163235 }
164236
165237 for _ , test := range tests {
0 commit comments