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/note_test.go
2023-10-24 15:10:39 +02:00

59 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-sdk-go/pkg/e621/model"
"github.com/jarcoal/httpmock"
"net/http"
"testing"
)
func TestGetNote(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()
noteResponse := model.Note{
ID: 385777,
CreatedAt: "2023-10-19T06:42:20.171-04:00",
UpdatedAt: "2023-10-19T06:42:20.171-04:00",
CreatorID: 1472475,
X: 277,
Y: 841,
Width: 101,
Height: 176,
Version: 2,
IsActive: true,
PostID: 2624329,
Body: "Well, isnt it just right to use them?",
CreatorName: "ponypussypounder",
}
jsonResponser, err := httpmock.NewJsonResponder(200, noteResponse)
if err != nil {
t.Error(err)
return
}
httpmock.RegisterResponder("GET", "https://e621.net/notes/36957.json", jsonResponser)
requestContext := model.RequestContext{
Client: http.Client{},
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (@username)",
Username: "memo",
APIKey: "123456",
}
getNote := NewGetNoteBuilder(requestContext)
pool, err := getNote.SetNoteID(36957).Execute()
if err != nil {
t.Error(err)
return
}
if pool.ID == noteResponse.ID && pool.Body == noteResponse.Body {
return
}
t.Errorf("Respons did not match mock data:\nOriginal: %v\nMock: %v", pool, noteResponse)
}