github.com/aavshr/aws-sdk-go@v1.41.3/service/polly/customizations_test.go (about) 1 package polly 2 3 import ( 4 "regexp" 5 "testing" 6 "time" 7 8 "github.com/aavshr/aws-sdk-go/aws" 9 "github.com/aavshr/aws-sdk-go/awstesting/unit" 10 ) 11 12 func TestRestGETStrategy(t *testing.T) { 13 svc := New(unit.Session, &aws.Config{Region: aws.String("us-west-2")}) 14 r, _ := svc.SynthesizeSpeechRequest(nil) 15 16 if err := restGETPresignStrategy(r); err != nil { 17 t.Error(err) 18 } 19 if "GET" != r.HTTPRequest.Method { 20 t.Errorf("Expected 'GET', but received %s", r.HTTPRequest.Method) 21 } 22 if r.Operation.BeforePresignFn == nil { 23 t.Error("Expected non-nil value for 'BeforePresignFn'") 24 } 25 } 26 27 func TestPresign(t *testing.T) { 28 svc := New(unit.Session, &aws.Config{Region: aws.String("us-west-2")}) 29 r, _ := svc.SynthesizeSpeechRequest(&SynthesizeSpeechInput{ 30 Text: aws.String("Moo"), 31 OutputFormat: aws.String("mp3"), 32 VoiceId: aws.String("Foo"), 33 }) 34 url, err := r.Presign(time.Second) 35 36 if err != nil { 37 t.Error(err) 38 } 39 expectedURL := `^https://polly.us-west-2.amazonaws.com/v1/speech\?.*?OutputFormat=mp3.*?Text=Moo.*?VoiceId=Foo.*` 40 if matched, err := regexp.MatchString(expectedURL, url); !matched || err != nil { 41 t.Errorf("Expected:\n%q\nReceived:\n%q\nError:\n%v\n", expectedURL, url, err) 42 } 43 }