Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for various expressions #683

Merged
merged 1 commit into from Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 70 additions & 0 deletions pkg/tf2pulumi/convert/testdata/expressions/main.tf
@@ -0,0 +1,70 @@
output "null_out" {
value = null
}

output "number_out" {
value = 0
}

output "bool_out" {
value = true
}

output "string_out" {
value = "hello world"
}

output "tuple_out" {
value = [1, 2, 3]
}

output "str_object_out" {
value = {
hello: "hallo"
goodbye: "ha det"
}
}

locals {
a_key = "hello"
a_value = -1
}

output "complex_object_out" {
value = {
a_tuple: ["a", "b", "c"]
an_object: {
literal_key: 1
another_literal_key = 2
"yet_another_literal_key": local.a_value
# This doesn't translate correctly
# (local.a_key) = 4
}
ambiguous_for: {
"for" = 1
}
}
}

output "quoted_template" {
value = "The key is ${local.a_key}"
}

output "heredoc" {
value = <<END
This is also a template.
So we can output the key again ${local.a_key}
END
}

output "for_tuple" {
value = [for key, value in ["a", "b"] : "${key}:${value}:${local.a_value}" if key != 0]
}

output "for_tuple_value_only" {
value = [for value in ["a", "b"] : "${value}:${local.a_value}"]
}

output "for_object" {
value = {for key, value in ["a", "b"] : key => "${value}:${local.a_value}" if key != 0}
}
56 changes: 56 additions & 0 deletions pkg/tf2pulumi/convert/testdata/expressions/pcl/main.pp
@@ -0,0 +1,56 @@
output nullOut {
value = null
}
output numberOut {
value = 0
}
output boolOut {
value = true
}
output stringOut {
value = "hello world"
}
output tupleOut {
value = [1, 2, 3]
}
output strObjectOut {
value = {
hello: "hallo"
goodbye: "ha det"
}
}
aKey = "hello"
aValue = -1
output complexObjectOut {
value = {
a_tuple: ["a", "b", "c"]
an_object: {
literal_key: 1
another_literal_key = 2
"yet_another_literal_key": aValue
# This doesn't translate correctly
# (local.a_key) = 4
}
ambiguous_for: {
"for" = 1
}
}
}
output quotedTemplate {
value = "The key is ${aKey}"
}
output heredoc {
value = <<END
This is also a template.
So we can output the key again ${aKey}
END
}
output forTuple {
value = [for key, value in ["a", "b"] : "${key}:${value}:${aValue}" if key != 0]
}
output forTupleValueOnly {
value = [for value in ["a", "b"] : "${value}:${aValue}"]
}
output forObject {
value = {for key, value in ["a", "b"] : key => "${value}:${aValue}" if key != 0}
}