customizations_test.go 941 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package machinelearning_test
  2. import (
  3. "bytes"
  4. "io/ioutil"
  5. "net/http"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/aws/aws-sdk-go/aws"
  9. "github.com/aws/aws-sdk-go/aws/request"
  10. "github.com/aws/aws-sdk-go/awstesting/unit"
  11. "github.com/aws/aws-sdk-go/service/machinelearning"
  12. )
  13. func TestPredictEndpoint(t *testing.T) {
  14. ml := machinelearning.New(unit.Session)
  15. ml.Handlers.Send.Clear()
  16. ml.Handlers.Send.PushBack(func(r *request.Request) {
  17. r.HTTPResponse = &http.Response{
  18. StatusCode: 200,
  19. Header: http.Header{},
  20. Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))),
  21. }
  22. })
  23. req, _ := ml.PredictRequest(&machinelearning.PredictInput{
  24. PredictEndpoint: aws.String("https://localhost/endpoint"),
  25. MLModelId: aws.String("id"),
  26. Record: map[string]*string{},
  27. })
  28. err := req.Send()
  29. assert.Nil(t, err)
  30. assert.Equal(t, "https://localhost/endpoint", req.HTTPRequest.URL.String())
  31. }