v1_test.go 786 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dpsapi
  2. import (
  3. "git.sxidc.com/go-tools/api_binding/http_binding"
  4. "git.sxidc.com/go-tools/api_binding/http_binding/response"
  5. "github.com/go-resty/resty/v2"
  6. "testing"
  7. )
  8. func TestApiV1(t *testing.T) {
  9. http_binding.Init("test", "10086")
  10. defer http_binding.Destroy()
  11. binding := http_binding.NewBinding("v1")
  12. ApiV1(binding, "localhost:30170")
  13. result := new(response.MsgResponse)
  14. resp, err := resty.New().R().
  15. SetBody(&OperateFromRequest{
  16. DatabaseID: "ee2d7dabe56646ce835d80873348ee0e",
  17. Version: "v1",
  18. SQL: sqlSelect,
  19. }).
  20. SetResult(result).
  21. Post("http://localhost:10086/test/api/v1/dpsv1/database/operate")
  22. if err != nil {
  23. t.Fatal(err)
  24. }
  25. if resp.IsError() {
  26. t.Fatal(resp.Status())
  27. }
  28. if !result.Success {
  29. t.Fatal(result.Msg)
  30. }
  31. }