jokes-bapak2/api/utils/request_test.go

25 lines
507 B
Go
Raw Permalink Normal View History

2021-07-09 12:13:19 +00:00
package utils_test
import (
2021-10-30 03:24:53 +00:00
"jokes-bapak2-api/utils"
2021-07-09 12:13:19 +00:00
"net/http"
"testing"
)
2021-08-04 05:56:14 +00:00
func TestRequest_Get(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",
},
2021-07-09 12:13:19 +00:00
})
2021-08-04 05:56:14 +00:00
if err != nil {
t.Error(err.Error())
}
if res.StatusCode != 200 {
t.Error("response does not have 200 status", res.Status)
}
2021-07-09 12:13:19 +00:00
}