ISSUE 79: Create a more readable aws_route53_zone output

main
Louis TOUSSAINT 2021-02-02 20:05:47 +01:00
parent 738d2234ee
commit 04039f7aff
2 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,12 @@
package aws
import (
"fmt"
)
func (r *AwsRoute53Zone) String() string {
return *r.Name
if r.Name == nil {
return r.TerraformId()
}
return fmt.Sprintf("%s (Id: %s)", *r.Name, r.TerraformId())
}

View File

@ -12,11 +12,19 @@ func TestAwsRoute53Zone_String(t *testing.T) {
zone AwsRoute53Zone
want string
}{
{name: "",
{name: "test route53 zone stringer with name and id",
zone: AwsRoute53Zone{
Name: aws.String("example.com"),
Id: "Z04218102KCRRR1DWDYJT",
},
want: "example.com",
want: "example.com (Id: Z04218102KCRRR1DWDYJT)",
},
{name: "test route53 zone stringer without name",
zone: AwsRoute53Zone{
Name: nil,
Id: "Z04218102KCRRR1DWDYJT",
},
want: "Z04218102KCRRR1DWDYJT",
},
}
for _, tt := range tests {