github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/provider/ec2/instancetypes_test.go (about) 1 // Copyright 2020 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package ec2 5 6 import ( 7 "github.com/aws/aws-sdk-go-v2/service/ec2/types" 8 "github.com/juju/collections/set" 9 "github.com/juju/testing" 10 jc "github.com/juju/testing/checkers" 11 gc "gopkg.in/check.v1" 12 ) 13 14 type InstanceTypesSuite struct { 15 testing.IsolationSuite 16 } 17 18 var _ = gc.Suite(&InstanceTypesSuite{}) 19 20 func (s *InstanceTypesSuite) TestParseInstanceType(c *gc.C) { 21 tests := []struct { 22 InstType types.InstanceType 23 Expected instanceType 24 }{ 25 { 26 "m5.large", 27 instanceType{ 28 Capabilities: set.NewStrings(), 29 Generation: 5, 30 Family: "m", 31 ProcessorFamily: "i", 32 Size: "large", 33 }, 34 }, 35 { 36 "m5a.large", 37 instanceType{ 38 Capabilities: set.NewStrings(), 39 Generation: 5, 40 Family: "m", 41 ProcessorFamily: "a", 42 Size: "large", 43 }, 44 }, 45 { 46 "m5a.2xlarge", 47 instanceType{ 48 Capabilities: set.NewStrings(), 49 Generation: 5, 50 Family: "m", 51 ProcessorFamily: "a", 52 Size: "2xlarge", 53 }, 54 }, 55 { 56 "m5ad.large", 57 instanceType{ 58 Capabilities: set.NewStrings("d"), 59 Generation: 5, 60 Family: "m", 61 ProcessorFamily: "a", 62 Size: "large", 63 }, 64 }, 65 { 66 "m6g.24xlarge", 67 instanceType{ 68 Capabilities: set.NewStrings(), 69 Generation: 6, 70 Family: "m", 71 ProcessorFamily: "g", 72 Size: "24xlarge", 73 }, 74 }, 75 { 76 "m7gd.large", 77 instanceType{ 78 Capabilities: set.NewStrings("d"), 79 Generation: 7, 80 Family: "m", 81 ProcessorFamily: "g", 82 Size: "large", 83 }, 84 }, 85 { 86 "c5ad.large", 87 instanceType{ 88 Capabilities: set.NewStrings("d"), 89 Generation: 5, 90 Family: "c", 91 ProcessorFamily: "a", 92 Size: "large", 93 }, 94 }, 95 { 96 "r5a.metal", 97 instanceType{ 98 Capabilities: set.NewStrings(), 99 Generation: 5, 100 Family: "r", 101 ProcessorFamily: "a", 102 Size: "metal", 103 }, 104 }, 105 { 106 "Im4gn.large", 107 instanceType{ 108 Capabilities: set.NewStrings("n"), 109 Generation: 4, 110 Family: "Im", 111 ProcessorFamily: "g", 112 Size: "large", 113 }, 114 }, 115 { 116 "c4.large", 117 instanceType{ 118 Capabilities: set.NewStrings(), 119 Generation: 4, 120 Family: "c", 121 ProcessorFamily: "i", 122 Size: "large", 123 }, 124 }, 125 { 126 "mac2.metal", 127 instanceType{ 128 Capabilities: set.NewStrings(), 129 Generation: 2, 130 Family: "mac", 131 ProcessorFamily: "i", 132 Size: "metal", 133 }, 134 }, 135 } 136 137 for _, test := range tests { 138 it, err := parseInstanceType(test.InstType) 139 c.Assert(err, jc.ErrorIsNil) 140 c.Assert(it, jc.DeepEquals, test.Expected) 141 } 142 }