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 TestGetUsers(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
response, err := utils.LoadJsonTestData[[]model.User]("../../../tests/users.json")
if err != nil {
t.Error(err)
return
}
responser, err := httpmock.NewJsonResponder(200, response)
httpmock.RegisterResponder("GET", "https://e621.net/users.json", responser)
requestContext := model.RequestContext{
Client: http.Client{},
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (@username)",
Username: "memo",
APIKey: "123456",
getUsers := NewGetUsersBuilder(requestContext)
user, err := getUsers.Execute()
if user[0].ID == response[0].ID && user[1].Name == response[1].Name {
t.Errorf("Respons did not match mock data:\nOriginal: %v\nMock: %v", user, response)