|
5 | 5 |
|
6 | 6 | "github.com/infracost/go-proto/pkg/tree/aws" |
7 | 7 | "github.com/infracost/go-proto/pkg/tree/aws/ec2" |
| 8 | + "github.com/infracost/go-proto/pkg/tree/aws/eks" |
8 | 9 | "github.com/infracost/go-proto/pkg/tree/resource" |
9 | 10 | "github.com/infracost/go-proto/pkg/tree/value" |
10 | 11 | prototree "github.com/infracost/proto/gen/go/infracost/tree" |
@@ -87,6 +88,33 @@ func TestRoundTrip(t *testing.T) { |
87 | 88 | assert.Equal(t, "c5.xlarge", result.AWS.EC2.Instances[2].Type.Value()) |
88 | 89 | } |
89 | 90 |
|
| 91 | +func TestRoundTrip_ListField(t *testing.T) { |
| 92 | + original := &Tree{ |
| 93 | + AWS: aws.AWS{ |
| 94 | + EKS: eks.EKS{ |
| 95 | + NodeGroups: []eks.NodeGroup{{ |
| 96 | + InstanceTypes: *value.NewList([]value.Value[string]{ |
| 97 | + value.New("t3.micro", 0, "instance_types", nil), |
| 98 | + value.New("t3.small", 0, "instance_types", nil), |
| 99 | + }, 0, "instance_types", nil), |
| 100 | + }}, |
| 101 | + }, |
| 102 | + }, |
| 103 | + } |
| 104 | + |
| 105 | + proto, err := original.ToProto() |
| 106 | + require.NoError(t, err) |
| 107 | + |
| 108 | + result, err := FromProto(proto) |
| 109 | + require.NoError(t, err) |
| 110 | + |
| 111 | + require.Len(t, result.AWS.EKS.NodeGroups, 1) |
| 112 | + items := result.AWS.EKS.NodeGroups[0].InstanceTypes.Items() |
| 113 | + require.Len(t, items, 2, "list items should survive proto round-trip") |
| 114 | + assert.Equal(t, "t3.micro", items[0].Value()) |
| 115 | + assert.Equal(t, "t3.small", items[1].Value()) |
| 116 | +} |
| 117 | + |
90 | 118 | func TestFromProtoUnmappedProvider(t *testing.T) { |
91 | 119 | proto := &prototree.Tree{ |
92 | 120 | Providers: map[string]*prototree.Provider{ |
|
0 commit comments