github.com/openshift/installer@v1.4.17/pkg/asset/installconfig/aws/session_test.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 9 typesaws "github.com/openshift/installer/pkg/types/aws" 10 ) 11 12 func TestAWSResolver(t *testing.T) { 13 overrides := []typesaws.ServiceEndpoint{{ 14 Name: "ec2", 15 URL: "test-ec2.local", 16 }, { 17 Name: "s3", 18 URL: "https://test-s3.local", 19 }} 20 21 cases := []struct { 22 iservice, iregion string 23 overrides []typesaws.ServiceEndpoint 24 expected string 25 }{{ 26 iservice: "ec2", 27 iregion: "us-east-1", 28 expected: "https://ec2.us-east-1.amazonaws.com", 29 }, { 30 iservice: "ec2", 31 iregion: "us-east-1", 32 overrides: overrides, 33 expected: "test-ec2.local", 34 }, { 35 iservice: "s3", 36 iregion: "us-east-1", 37 overrides: overrides, 38 expected: "https://test-s3.local", 39 }, { 40 iservice: "elasticloadbalancing", 41 iregion: "us-east-1", 42 overrides: overrides, 43 expected: "https://elasticloadbalancing.us-east-1.amazonaws.com", 44 }} 45 for idx, test := range cases { 46 t.Run(fmt.Sprintf("%d", idx), func(t *testing.T) { 47 resolvers := newAWSResolver(test.iregion, test.overrides) 48 endpoint, err := resolvers.EndpointFor(test.iservice, test.iregion) 49 assert.NoError(t, err) 50 assert.Equal(t, test.expected, endpoint.URL) 51 }) 52 } 53 }