httpclient_test.go 412 B

123456789101112131415161718192021222324252627
  1. package beaconfire
  2. import (
  3. "encoding/json"
  4. "testing"
  5. )
  6. func TestGet(t *testing.T) {
  7. _, err := Get("http://www.google.com")
  8. if err != nil {
  9. t.Error(err)
  10. }
  11. }
  12. func TestPostJson(t *testing.T) {
  13. body, err := json.Marshal(map[string]string{
  14. "username": "test",
  15. "password": "123",
  16. })
  17. if err != nil {
  18. t.Error(err)
  19. }
  20. _, err = PostJson("http://google.com", body)
  21. if err != nil {
  22. t.Error(err)
  23. }
  24. }