-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46e4495
commit 0975f76
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package tfwrite | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestNestedBlockType(t *testing.T) { | ||
cases := []struct { | ||
desc string | ||
src string | ||
name string | ||
want string | ||
ok bool | ||
}{ | ||
{ | ||
desc: "simple", | ||
src: ` | ||
foo { | ||
nested { | ||
bar = "baz" | ||
} | ||
} | ||
`, | ||
name: "nested", | ||
want: "nested", | ||
ok: true, | ||
}, | ||
} | ||
|
||
for _, tc := range cases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
f := parseTestFile(t, tc.src) | ||
b := findFirstTestBlock(t, f) | ||
nestedBlocks := b.FindNestedBlocksByType(tc.name) | ||
|
||
got := nestedBlocks[0].Type() | ||
if got != tc.want { | ||
t.Errorf("got = %s, but want = %s", got, tc.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters