File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,6 +160,114 @@ func Test_tfrbac(t *testing.T) {
160160 },
161161 expected : nil ,
162162 },
163+ "resource-without-refactoring-block" : {
164+ args : args {
165+ input : []byte (
166+ `
167+ resource "AAA" "aaa" {
168+ }
169+ ` ),
170+ },
171+ expected : []byte (
172+ `
173+ resource "AAA" "aaa" {
174+ }
175+ ` ),
176+ },
177+ "import-block" : {
178+ args : args {
179+ input : []byte (
180+ `
181+ resource "aws_instance" "example" {
182+ }
183+
184+ import {
185+ to = aws_instance.example
186+ id = "i-abcd1234"
187+ }
188+ ` ),
189+ },
190+ expected : []byte (
191+ `
192+ resource "aws_instance" "example" {
193+ }
194+ ` ),
195+ },
196+ "removed-block" : {
197+ args : args {
198+ input : []byte (
199+ `
200+ removed {
201+ from = aws_instance.example
202+
203+ lifecycle {
204+ destroy = false
205+ }
206+ }
207+
208+ resource "aws_instance" "example" {
209+ }
210+ ` ),
211+ },
212+ expected : []byte (
213+ `
214+ resource "aws_instance" "example" {
215+ }
216+ ` ),
217+ },
218+ "multiple-import-blocks" : {
219+ args : args {
220+ input : []byte (
221+ `
222+ import {
223+ to = aws_instance.example
224+ id = "i-abcd1234"
225+ }
226+
227+ import {
228+ to = aws_s3_bucket.example
229+ id = "example"
230+ }
231+ ` ),
232+ },
233+ expected : []byte (
234+ `
235+ ` ),
236+ },
237+ "mixed-refactoring-blocks-between-resources" : {
238+ args : args {
239+ input : []byte (
240+ `
241+ resource "aws_instance" "before" {
242+ }
243+
244+ import {
245+ to = aws_instance.example
246+ id = "i-abcd1234"
247+ }
248+
249+ removed {
250+ from = aws_instance.old
251+ }
252+
253+ moved {
254+ from = aws_instance.old_name
255+ to = aws_instance.new_name
256+ }
257+
258+ resource "aws_instance" "after" {
259+ }
260+ ` ),
261+ },
262+ expected : []byte (
263+ `
264+ resource "aws_instance" "before" {
265+ }
266+
267+ resource "aws_instance" "after" {
268+ }
269+ ` ),
270+ },
163271 "simple-1-1" : {
164272 args : args {
165273 input : []byte (
You can’t perform that action at this time.
0 commit comments