2023-07-14 23:52:14 +02:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
H "net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type PostItem struct {
|
|
|
|
UserId uint `json:"userId"`
|
|
|
|
Id uint `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Body string `json:"body"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestSendSingleRequest(t *testing.T) {
|
|
|
|
|
|
|
|
client := MakeClient(H.DefaultClient)
|
|
|
|
|
2023-07-17 18:03:21 +02:00
|
|
|
req1 := MakeGetRequest("https://jsonplaceholder.typicode.com/posts/1")
|
2023-07-14 23:52:14 +02:00
|
|
|
|
|
|
|
readItem := ReadJson[PostItem](client)
|
|
|
|
|
|
|
|
resp1 := readItem(req1)
|
|
|
|
|
|
|
|
resE := resp1(context.Background())()
|
|
|
|
|
|
|
|
fmt.Println(resE)
|
|
|
|
}
|