customizations_test.go 990 B

123456789101112131415161718192021222324252627282930313233343536373839
  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/awstesting/unit"
  10. "github.com/aws/aws-sdk-go/service/machinelearning"
  11. )
  12. func TestPredictEndpoint(t *testing.T) {
  13. ml := machinelearning.New(unit.Session)
  14. ml.Handlers.Send.Clear()
  15. ml.Handlers.Send.PushBack(func(r *request.Request) {
  16. r.HTTPResponse = &http.Response{
  17. StatusCode: 200,
  18. Header: http.Header{},
  19. Body: ioutil.NopCloser(bytes.NewReader([]byte("{}"))),
  20. }
  21. })
  22. req, _ := ml.PredictRequest(&machinelearning.PredictInput{
  23. PredictEndpoint: aws.String("https://localhost/endpoint"),
  24. MLModelId: aws.String("id"),
  25. Record: map[string]*string{},
  26. })
  27. err := req.Send()
  28. if err != nil {
  29. t.Errorf("expect no error, got %v", err)
  30. }
  31. if e, a := "https://localhost/endpoint", req.HTTPRequest.URL.String(); e != a {
  32. t.Errorf("expect %v, got %v", e, a)
  33. }
  34. }