jokes-bapak2/api/app/v1/utils/request_test.go

28 lines
595 B
Go
Raw Normal View History

2021-07-09 12:13:19 +00:00
package utils_test
import (
"net/http"
"testing"
2021-07-14 18:17:01 +00:00
"jokes-bapak2-api/app/v1/utils"
2021-07-09 12:13:19 +00:00
)
func TestRequest(t *testing.T) {
t.Run("should be able to do a get request", func(t *testing.T) {
res, err := utils.Request(utils.RequestConfig{
URL: "https://jsonplaceholder.typicode.com/todos/1",
Method: http.MethodGet,
Headers: map[string]interface{}{
"User-Agent": "Jokesbapak2 Test API",
"Accept": "application/json",
},
})
if err != nil {
t.Error(err.Error())
}
if res.StatusCode != 200 {
t.Error("response does not have 200 status", res.Status)
}
})
}