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 TestGetFavorites(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() response, err := utils.LoadJsonTestData[model.PostResponse]("../../../tests/posts.json") if err != nil { t.Error(err) return } jsonResponser, err := httpmock.NewJsonResponder(200, response) if err != nil { t.Error(err) return } httpmock.RegisterResponder("GET", "https://e621.net/favorites.json", jsonResponser) requestContext := model.RequestContext{ Client: http.Client{}, Host: "https://e621.net", UserAgent: "Go-e621-SDK (@username)", Username: "memo", APIKey: "123456", } getFavorites := NewGetFavoritesBuilder(requestContext) posts, err := getFavorites.SetLimit(3).Execute() if err != nil { t.Error(err) return } if posts[0].ID == response.Posts[0].ID && posts[1].File.Md5 == response.Posts[1].File.Md5 && posts[2].File.EXT == response.Posts[2].File.EXT { return } t.Errorf("Respons did not match mock data:\nOriginal: %v\nMock: %v", posts, response) }