package builder
import (
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model"
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621/utils"
"github.com/jarcoal/httpmock"
"net/http"
"testing"
)
func TestGetPost(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
data, err := utils.LoadJsonTestData[model.Post]("../../../tests/post.json")
if err != nil {
t.Error(err)
return
}
response := model.PostResponse{
Post: data,
Posts: nil,
responser, err := httpmock.NewJsonResponder(200, response)
httpmock.RegisterResponder("GET", "https://e621.net/posts/658415636580.json", responser)
requestContext := model.RequestContext{
Client: http.Client{},
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (@username)",
Username: "memo",
APIKey: "123456",
getPost := NewGetPostBuilder(requestContext)
post, err := getPost.SetPostID(658415636580).Execute()
if post.ID == response.Post.ID && post.File.URL == response.Post.File.URL {
t.Errorf("Respons did not match mock data:\nOriginal: %v\nMock: %v", post, response)