(t *testing.T)
| 90 | } |
| 91 | |
| 92 | func TestDecodeRDSWithValueMapping(t *testing.T) { |
| 93 | records := []resources.ResourceRecord{ |
| 94 | { |
| 95 | Type: "aws:rds/instance:Instance", |
| 96 | Name: "my-postgres-db", |
| 97 | Inputs: resource.PropertyMap{ |
| 98 | "instanceClass": resource.NewStringProperty("db.t3.medium"), |
| 99 | "engine": resource.NewStringProperty("postgres"), |
| 100 | "multiAz": resource.NewBoolProperty(true), |
| 101 | }, |
| 102 | MockedProperties: map[string]string{"region": "us-east-1"}, |
| 103 | }, |
| 104 | } |
| 105 | |
| 106 | meta := &api.MetadataResponse{ |
| 107 | PulumiResources: map[string]api.PulumiResourceDef{ |
| 108 | "aws:rds/instance:Instance": { |
| 109 | Provider: "aws", |
| 110 | Product: "RDS Instance", |
| 111 | Attrs: map[string]api.PulumiAttrMapping{ |
| 112 | "instance_type": {Input: "instanceClass"}, |
| 113 | "database_engine": {Input: "engine", Map: map[string]string{ |
| 114 | "postgres": "PostgreSQL", "mysql": "MySQL", |
| 115 | }}, |
| 116 | "deployment_option": {Input: "multiAz", Default: "Single-AZ", Map: map[string]string{ |
| 117 | "true": "Multi-AZ", "false": "Single-AZ", |
| 118 | }}, |
| 119 | "license_model": {Default: "No License required"}, |
| 120 | }, |
| 121 | }, |
| 122 | }, |
| 123 | } |
| 124 | |
| 125 | decoded := DecodeAllResources(records, meta) |
| 126 | if len(decoded) != 1 { |
| 127 | t.Fatalf("expected 1 decoded resource, got %d", len(decoded)) |
| 128 | } |
| 129 | |
| 130 | d := decoded[0] |
| 131 | checks := map[string]string{ |
| 132 | "instance_type": "db.t3.medium", |
| 133 | "database_engine": "PostgreSQL", |
| 134 | "deployment_option": "Multi-AZ", |
| 135 | "license_model": "No License required", |
| 136 | } |
| 137 | for attr, want := range checks { |
| 138 | got := d.Attrs[attr] |
| 139 | if got != want { |
| 140 | t.Errorf("attr %q = %q, want %q", attr, got, want) |
| 141 | } |
| 142 | } |
| 143 | if d.Provider != "aws" { |
| 144 | t.Errorf("provider = %q, want aws", d.Provider) |
| 145 | } |
| 146 | if d.Region != "us-east-1" { |
| 147 | t.Errorf("region = %q, want us-east-1", d.Region) |
| 148 | } |
| 149 | } |
nothing calls this directly
no test coverage detected