MCPcopy Index your code
hub / github.com/go-telegram/bot / TestBot_Methods

Function TestBot_Methods

methods_test.go:60–1391  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestBot_Methods(t *testing.T) {
61 t.Parallel()
62
63 t.Run("SetWebhook", func(t *testing.T) {
64 c := &httpClient{t: t, resp: `true`, reqFields: map[string]string{
65 "url": "https://domain.com",
66 "ip_address": "1.2.3.4",
67 "max_connections": "1",
68 }}
69 b := &Bot{client: c}
70 resp, err := b.SetWebhook(context.Background(), &SetWebhookParams{
71 URL: "https://domain.com",
72 IPAddress: "1.2.3.4",
73 MaxConnections: 1,
74 })
75 assertNoErr(t, err)
76 assertTrue(t, resp)
77 })
78
79 t.Run("GetWebhookInfo", func(t *testing.T) {
80 c := &httpClient{t: t, resp: `{"url":"https://domain.com"}`}
81 b := &Bot{client: c}
82 resp, err := b.GetWebhookInfo(context.Background())
83 assertNoErr(t, err)
84 assertEqualString(t, resp.URL, "https://domain.com")
85 })
86
87 t.Run("DeleteWebhook", func(t *testing.T) {
88 c := &httpClient{t: t, resp: "true", reqFields: map[string]string{
89 "drop_pending_updates": "true",
90 }}
91 b := &Bot{client: c}
92 resp, err := b.DeleteWebhook(context.Background(), &DeleteWebhookParams{
93 DropPendingUpdates: true,
94 })
95 assertNoErr(t, err)
96 assertTrue(t, resp)
97 })
98
99 t.Run("GetMe", func(t *testing.T) {
100 c := &httpClient{t: t, resp: `{"username":"foo"}`}
101 b := &Bot{client: c}
102 resp, err := b.GetMe(context.Background())
103 assertNoErr(t, err)
104 assertEqualString(t, resp.Username, "foo")
105 })
106
107 t.Run("Logout", func(t *testing.T) {
108 c := &httpClient{t: t, resp: `true`}
109 b := &Bot{client: c}
110 resp, err := b.Logout(context.Background())
111 assertNoErr(t, err)
112 assertTrue(t, resp)
113 })
114
115 t.Run("Close", func(t *testing.T) {
116 c := &httpClient{t: t, resp: `true`}
117 b := &Bot{client: c}

Callers

nothing calls this directly

Calls 15

SetWebhookMethod · 0.95
GetWebhookInfoMethod · 0.95
DeleteWebhookMethod · 0.95
GetMeMethod · 0.95
LogoutMethod · 0.95
CloseMethod · 0.95
SendMessageMethod · 0.95
ForwardMessageMethod · 0.95
CopyMessageMethod · 0.95
SendPhotoMethod · 0.95
SendAudioMethod · 0.95
SendDocumentMethod · 0.95

Tested by

no test coverage detected