(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func 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} |
nothing calls this directly
no test coverage detected