🙂 Fix codestyle and some things
This commit is contained in:
parent
e2253e159d
commit
fe87b5a44a
|
@ -5,7 +5,7 @@
|
||||||
[![Build Status](https://travis-ci.org/toby3d/telegraph.svg)](https://travis-ci.org/toby3d/telegraph)
|
[![Build Status](https://travis-ci.org/toby3d/telegraph.svg)](https://travis-ci.org/toby3d/telegraph)
|
||||||
[![GoDoc](https://godoc.org/github.com/toby3d/telegraph?status.svg)](https://godoc.org/github.com/toby3d/telegraph)
|
[![GoDoc](https://godoc.org/github.com/toby3d/telegraph?status.svg)](https://godoc.org/github.com/toby3d/telegraph)
|
||||||
[![Go Report](https://goreportcard.com/badge/github.com/toby3d/telegraph)](https://goreportcard.com/report/github.com/toby3d/telegraph)
|
[![Go Report](https://goreportcard.com/badge/github.com/toby3d/telegraph)](https://goreportcard.com/report/github.com/toby3d/telegraph)
|
||||||
[![Patreon](https://img.shields.io/badge/support-patreon-E66500.svg?maxAge=2592000)](https://www.patreon.com/toby3d)
|
[![Patreon](https://img.shields.io/badge/support-patreon-E6461A.svg?maxAge=2592000)](https://www.patreon.com/toby3d)
|
||||||
|
|
||||||
All [methods](http://telegra.ph/api#Available-methods) and [types](http://telegra.ph/api#Available-types) available! Yaay!
|
All [methods](http://telegra.ph/api#Available-methods) and [types](http://telegra.ph/api#Available-types) available! Yaay!
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,9 @@ package telegraph
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/valyala/fasthttp"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateAccount create a new Telegraph account. Most users only need one
|
// CreateAccount create a new Telegraph account. Most users only need one
|
||||||
|
|
|
@ -4,8 +4,9 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/net/html"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/net/html"
|
||||||
)
|
)
|
||||||
|
|
||||||
var availableTags = map[string]bool{
|
var availableTags = map[string]bool{
|
||||||
|
|
3
page.go
3
page.go
|
@ -3,8 +3,9 @@ package telegraph
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/valyala/fasthttp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreatePage create a new Telegraph page. On success, returns a Page object.
|
// CreatePage create a new Telegraph page. On success, returns a Page object.
|
||||||
|
|
|
@ -5,6 +5,7 @@ package telegraph
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -132,13 +133,13 @@ type (
|
||||||
)
|
)
|
||||||
|
|
||||||
func request(url string, args *fasthttp.Args) (*Response, error) {
|
func request(url string, args *fasthttp.Args) (*Response, error) {
|
||||||
_, res, err := fasthttp.Post(nil, url, args)
|
_, resp, err := fasthttp.Post(nil, url, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var tResp Response
|
var tResp Response
|
||||||
if err := json.Unmarshal(res, &tResp); err != nil {
|
if err := json.Unmarshal(resp, &tResp); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ func TestCreateValidAccount(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
demoAccount = *account
|
demoAccount = *account
|
||||||
t.Logf("New account created!\n%#v", *account)
|
t.Logf("New account created!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateValidPage(t *testing.T) {
|
func TestCreateValidPage(t *testing.T) {
|
||||||
|
@ -61,12 +61,12 @@ func TestEditValidAccountInfo(t *testing.T) {
|
||||||
AuthorURL: "https://telegram.me/telegraph",
|
AuthorURL: "https://telegram.me/telegraph",
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := demoAccount.EditAccountInfo(update)
|
_, err := demoAccount.EditAccountInfo(update)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Account updated!\n%#v", *info)
|
t.Logf("Account updated!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEditValidPage(t *testing.T) {
|
func TestEditValidPage(t *testing.T) {
|
||||||
|
@ -96,7 +96,7 @@ func TestGetValidAccountInfo(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("Account info:\n%#v", *account)
|
t.Logf("%s create %d pages", account.ShortName, account.PageCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetValidPageList(t *testing.T) {
|
func TestGetValidPageList(t *testing.T) {
|
||||||
|
@ -127,12 +127,10 @@ func TestGetValidViews(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRevokeAccessToken(t *testing.T) {
|
func TestRevokeAccessToken(t *testing.T) {
|
||||||
t.Logf("Old Access Token: %s", demoAccount.AccessToken)
|
_, err := demoAccount.RevokeAccessToken()
|
||||||
|
|
||||||
token, err := demoAccount.RevokeAccessToken()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Logf("New Access Token: %s", token.AccessToken)
|
t.Logf("New Access Token set!")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue