Skip to content

Commit

Permalink
Codify instance type names
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailshilkov committed Apr 15, 2024
1 parent 6623fc6 commit c90c65c
Show file tree
Hide file tree
Showing 9 changed files with 624 additions and 505 deletions.
7 changes: 6 additions & 1 deletion provider/cmd/pulumi-resource-aws/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -39645,7 +39645,7 @@
"value": "m5ad.large"
},
{
"name": "M5as_XLarge",
"name": "M5ad_XLarge",
"value": "m5ad.xlarge"
},
{
Expand Down Expand Up @@ -40687,6 +40687,11 @@
"name": "Hs1_8XLarge",
"value": "hs1.8xlarge",
"deprecationMessage": "This instancetype has been deprecated"
},
{
"name": "M5as_XLarge",
"value": "m5ad.xlarge",
"deprecationMessage": "Has a typo, use M5ad_XLarge instead"
}
]
},
Expand Down
46 changes: 46 additions & 0 deletions provider/enum_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2016-2024, Pulumi Corporation.

package provider

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestInstanceTypeName(t *testing.T) {
type testCase struct {
Value string
Name string
}

testCases := []testCase{
{Name: "A1_2XLarge", Value: "a1.2xlarge"},
{Name: "A1_Metal", Value: "a1.metal"},
{Name: "C6a_Large", Value: "c6a.large"},
{Name: "C7g_Medium", Value: "c7g.medium"},
{Name: "M1_Small", Value: "m1.small"},
{Name: "M7a_Metal", Value: "m7a.metal-48xl"},
{Name: "T1_Micro", Value: "t1.micro"},
{Name: "T2_Nano", Value: "t2.nano"},
}

for _, tc := range testCases {
actual, err := instanceTypeName(tc.Value)
assert.NoError(t, err)
assert.Equal(t, tc.Name, actual)
}
}

func TestInstanceTypeNameErr(t *testing.T) {
testCases := []string{
"a1.metal.pc",
"m7a.metal-96xl",
}

for _, tc := range testCases {
actual, err := instanceTypeName(tc)
assert.Error(t, err)
assert.Equal(t, "", actual)
}
}

0 comments on commit c90c65c

Please sign in to comment.