This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/pkg/e621/builder/pool_test.go
SoXX 989f853d72 feat: added mid-level API for pools
Signed-off-by: SoXX <soxx@fenpa.ws>
2023-10-23 14:27:20 +02:00

57 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package builder
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"
)
func TestGetPool(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
poolResponse := model.Pool{
ID: 36957,
Name: "MLP:His_Nocturnal_Excellency",
CreatedAt: "2023-10-13T19:24:00.576-04:00",
UpdatedAt: "2023-10-19T07:46:00.267-04:00",
CreatorID: 16883,
Description: "Two (un)lucky royal guards who saw something they didnt have to~",
IsActive: true,
Category: "series",
PostIDS: nil,
CreatorName: "2DUK",
PostCount: 11,
}
jsonResponser, err := httpmock.NewJsonResponder(200, poolResponse)
if err != nil {
t.Error(err)
return
}
httpmock.RegisterResponder("GET", "https://e621.net/pools/36957.json", jsonResponser)
requestContext := model.RequestContext{
Client: http.Client{},
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (@username)",
Username: "memo",
APIKey: "123456",
}
getPool := NewGetPoolBuilder(requestContext)
pool, err := getPool.ID(36957).Execute()
if err != nil {
t.Error(err)
return
}
if pool.ID == poolResponse.ID && pool.Name == poolResponse.Name {
return
}
t.Errorf("Respons did not match mock data:\nOriginal: %v\nMock: %v", pool, poolResponse)
}