-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrenotes_test.go
67 lines (56 loc) · 1.42 KB
/
renotes_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package notes_test
import (
"log"
"net/http"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/yitsushi/go-misskey"
"github.com/yitsushi/go-misskey/core"
"github.com/yitsushi/go-misskey/services/notes"
"github.com/yitsushi/go-misskey/test"
)
func TestService_Renotes(t *testing.T) {
client := test.MakeMockClient(test.SimpleMockOptions{
Endpoint: "/api/notes/renotes",
RequestData: ¬es.RenotesRequest{},
ResponseFile: "renotes.json",
StatusCode: http.StatusOK,
})
renotes, err := client.Notes().Renotes(notes.RenotesRequest{
Limit: 10,
NoteID: "asd",
})
if !assert.NoError(t, err) {
return
}
assert.Len(t, renotes, 2)
assert.Equal(t, "8du8xuvc67", renotes[0].ID)
assert.Equal(t, "83tcps73of", renotes[0].User.ID)
}
func TestRenotesRequest_Validate(t *testing.T) {
test.ValidateRequests(
t,
[]core.BaseRequest{
notes.RenotesRequest{},
notes.RenotesRequest{NoteID: "asd"},
},
[]core.BaseRequest{
notes.RenotesRequest{NoteID: "asd", Limit: 20},
},
)
}
func ExampleService_Renotes() {
client, _ := misskey.NewClientWithOptions(misskey.WithSimpleConfig("https://slippy.xyz", os.Getenv("MISSKEY_TOKEN")))
renotes, err := client.Notes().Renotes(notes.RenotesRequest{
NoteID: "8dsk7x47y3",
Limit: 10,
})
if err != nil {
log.Printf("[Notes/Renotes] %s", err)
return
}
for _, renote := range renotes {
log.Printf("[Notes/Renotes] %s", renote.User.Name)
}
}