github.com/aavshr/aws-sdk-go@v1.41.3/service/machinelearning/customizations_test.go (about) 1 package machinelearning_test 2 3 import ( 4 "bytes" 5 "io/ioutil" 6 "net/http" 7 "testing" 8 9 "github.com/aavshr/aws-sdk-go/aws" 10 "github.com/aavshr/aws-sdk-go/aws/request" 11 "github.com/aavshr/aws-sdk-go/awstesting/unit" 12 "github.com/aavshr/aws-sdk-go/service/machinelearning" 13 ) 14 15 func TestPredictEndpoint(t *testing.T) { 16 ml := machinelearning.New(unit.Session) 17 ml.Handlers.Send.Clear() 18 ml.Handlers.Send.PushBack(func(r *request.Request) { 19 r.HTTPResponse = &http.Response{ 20 StatusCode: 200, 21 Header: http.Header{}, 22 Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))), 23 } 24 }) 25 26 req, _ := ml.PredictRequest(&machinelearning.PredictInput{ 27 PredictEndpoint: aws.String("https://localhost/endpoint"), 28 MLModelId: aws.String("id"), 29 Record: map[string]*string{}, 30 }) 31 err := req.Send() 32 33 if err != nil { 34 t.Errorf("expect no error, got %v", err) 35 } 36 if e, a := "https://localhost/endpoint", req.HTTPRequest.URL.String(); e != a { 37 t.Errorf("expect %v, got %v", e, a) 38 } 39 }