♿ Make Account fields as constants
It helps to avoid typos in the listing of GetAccountInfo arguments
This commit is contained in:
parent
a979bbbb5d
commit
95664dde08
|
@ -8,8 +8,26 @@ import (
|
||||||
http "github.com/valyala/fasthttp"
|
http "github.com/valyala/fasthttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetAccountInfo get information about a Telegraph account. Returns an
|
const (
|
||||||
// Account object on success.
|
// FieldShortName used as GetAccountInfo argument for getting account name.
|
||||||
|
FieldShortName = "short_name"
|
||||||
|
|
||||||
|
// FieldAuthorName used as GetAccountInfo argument for getting author name.
|
||||||
|
FieldAuthorName = "author_name"
|
||||||
|
|
||||||
|
// FieldAuthorURL used as GetAccountInfo argument for getting profile link.
|
||||||
|
FieldAuthorURL = "author_url"
|
||||||
|
|
||||||
|
// FieldAuthURL used as GetAccountInfo argument for getting URL to authorize a browser on
|
||||||
|
// telegra.ph.
|
||||||
|
FieldAuthURL = "auth_url"
|
||||||
|
|
||||||
|
// FieldPageCount used as GetAccountInfo argument for getting number of pages belonging to the
|
||||||
|
// Telegraph account.
|
||||||
|
FieldPageCount = "page_count"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetAccountInfo get information about a Telegraph account. Returns an Account object on success.
|
||||||
func (account *Account) GetAccountInfo(fields ...string) (*Account, error) {
|
func (account *Account) GetAccountInfo(fields ...string) (*Account, error) {
|
||||||
args := http.AcquireArgs()
|
args := http.AcquireArgs()
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ func testInvalidEditPage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInvalidGetAccountInfo(t *testing.T) {
|
func testInvalidGetAccountInfo(t *testing.T) {
|
||||||
if _, err := invalidAccount.GetAccountInfo("short_name", "page_count"); err == nil {
|
if _, err := invalidAccount.GetAccountInfo(FieldShortName, FieldPageCount); err == nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ func testValidEditPage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testValidGetAccountInfo(t *testing.T) {
|
func testValidGetAccountInfo(t *testing.T) {
|
||||||
info, err := validAccount.GetAccountInfo("short_name", "page_count")
|
info, err := validAccount.GetAccountInfo(FieldShortName, FieldPageCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err.Error())
|
t.Error(err.Error())
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
|
|
Loading…
Reference in New Issue