customizations_test.go 957 B

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