🚨 Removed linter warnings
This commit is contained in:
parent
4e66fba526
commit
aaccc5766c
|
@ -41,7 +41,7 @@ func domToNode(domNode *html.Node) interface{} {
|
|||
return nil
|
||||
}
|
||||
|
||||
var nodeElement NodeElement
|
||||
nodeElement := new(NodeElement)
|
||||
|
||||
switch strings.ToLower(domNode.Data) {
|
||||
case "a", "aside", "b", "blockquote", "br", "code", "em", "figcaption", "figure", "h3", "h4", "hr", "i",
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestContentFormat(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
_, err := ContentFormat(42)
|
||||
assert.EqualError(t, ErrInvalidDataType, err.Error())
|
||||
_, err := telegraph.ContentFormat(42)
|
||||
assert.EqualError(t, telegraph.ErrInvalidDataType, err.Error())
|
||||
})
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
t.Run("string", func(t *testing.T) {
|
||||
validContentDOM, err := ContentFormat(`<p>Hello, World!</p>`)
|
||||
validContentDOM, err := telegraph.ContentFormat(`<p>Hello, World!</p>`)
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, validContentDOM)
|
||||
})
|
||||
t.Run("bytes", func(t *testing.T) {
|
||||
validContentDOM, err := ContentFormat([]byte(`<p>Hello, World!</p>`))
|
||||
validContentDOM, err := telegraph.ContentFormat([]byte(`<p>Hello, World!</p>`))
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, validContentDOM)
|
||||
})
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestCreateAccount(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Run("nil", func(t *testing.T) {
|
||||
_, err := CreateAccount(Account{})
|
||||
_, err := telegraph.CreateAccount(telegraph.Account{})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("without shortname", func(t *testing.T) {
|
||||
_, err := CreateAccount(Account{
|
||||
_, err := telegraph.CreateAccount(telegraph.Account{
|
||||
ShortName: "",
|
||||
AuthorName: "Anonymous",
|
||||
})
|
||||
|
@ -21,7 +22,7 @@ func TestCreateAccount(t *testing.T) {
|
|||
})
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
account, err := CreateAccount(Account{
|
||||
account, err := telegraph.CreateAccount(telegraph.Account{
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
})
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestCreatePage(t *testing.T) {
|
||||
content, err := ContentFormat(`<p>Hello, world!</p>`)
|
||||
content, err := telegraph.ContentFormat(`<p>Hello, world!</p>`)
|
||||
assert.NoError(t, err)
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var a Account
|
||||
_, err := a.CreatePage(Page{
|
||||
var a telegraph.Account
|
||||
_, err := a.CreatePage(telegraph.Page{
|
||||
Title: "Sample Page",
|
||||
AuthorName: "Anonymous",
|
||||
Content: content,
|
||||
|
@ -20,13 +21,13 @@ func TestCreatePage(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a := Account{
|
||||
a := telegraph.Account{
|
||||
AccessToken: "b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb",
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
}
|
||||
|
||||
page, err := a.CreatePage(Page{
|
||||
page, err := a.CreatePage(telegraph.Page{
|
||||
Title: "Sample Page",
|
||||
AuthorName: "Anonymous",
|
||||
Content: content,
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestEditAccountInfo(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var a Account
|
||||
_, err := a.EditAccountInfo(Account{})
|
||||
var a telegraph.Account
|
||||
_, err := a.EditAccountInfo(telegraph.Account{})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a := Account{
|
||||
a := telegraph.Account{
|
||||
AccessToken: "b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb",
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
}
|
||||
|
||||
_, err := a.EditAccountInfo(Account{
|
||||
_, err := a.EditAccountInfo(telegraph.Account{
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
})
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestEditPage(t *testing.T) {
|
||||
content, err := ContentFormat("<p>Hello, world!</p>")
|
||||
content, err := telegraph.ContentFormat("<p>Hello, world!</p>")
|
||||
assert.NoError(t, err)
|
||||
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var a Account
|
||||
_, err := a.EditPage(Page{
|
||||
var a telegraph.Account
|
||||
_, err := a.EditPage(telegraph.Page{
|
||||
Title: "Sample Page",
|
||||
AuthorName: "Anonymous",
|
||||
Content: content,
|
||||
|
@ -20,13 +21,13 @@ func TestEditPage(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a := Account{
|
||||
a := telegraph.Account{
|
||||
AccessToken: "b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb",
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
}
|
||||
|
||||
page, err := a.EditPage(Page{
|
||||
page, err := a.EditPage(telegraph.Page{
|
||||
Path: "Sample-Page-12-15",
|
||||
Title: "Sample Page",
|
||||
AuthorName: "Anonymous",
|
||||
|
|
|
@ -1,25 +1,26 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestGetAccountInfo(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var a Account
|
||||
var a telegraph.Account
|
||||
_, err := a.GetAccountInfo()
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a := Account{
|
||||
a := telegraph.Account{
|
||||
AccessToken: "b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb",
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
}
|
||||
|
||||
info, err := a.GetAccountInfo(FieldShortName, FieldPageCount)
|
||||
info, err := a.GetAccountInfo(telegraph.FieldShortName, telegraph.FieldPageCount)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, a.ShortName, info.ShortName)
|
||||
assert.NotZero(t, info.PageCount)
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestGetPageList(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var a Account
|
||||
var a telegraph.Account
|
||||
_, err := a.GetPageList(0, 0)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a := Account{
|
||||
a := telegraph.Account{
|
||||
AccessToken: "b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb",
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestGetPage(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
_, err := GetPage("wtf", true)
|
||||
_, err := telegraph.GetPage("wtf", true)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
page, err := GetPage("Sample-Page-12-15", true)
|
||||
page, err := telegraph.GetPage("Sample-Page-12-15", true)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, page)
|
||||
})
|
||||
|
|
|
@ -1,45 +1,46 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestGetViews(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
t.Run("path", func(t *testing.T) {
|
||||
_, err := GetViews("wtf", time.Time{})
|
||||
_, err := telegraph.GetViews("wtf", time.Time{})
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("year", func(t *testing.T) {
|
||||
dt := time.Date(1980, 0, 0, 0, 0, 0, 0, time.UTC)
|
||||
_, err := GetViews("Sample-Page-12-15", dt)
|
||||
_, err := telegraph.GetViews("Sample-Page-12-15", dt)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("month", func(t *testing.T) {
|
||||
dt := time.Date(2000, 22, 0, 0, 0, 0, 0, time.UTC)
|
||||
result, err := GetViews("Sample-Page-12-15", dt)
|
||||
result, err := telegraph.GetViews("Sample-Page-12-15", dt)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
t.Run("day", func(t *testing.T) {
|
||||
dt := time.Date(2000, time.February, 42, 0, 0, 0, 0, time.UTC)
|
||||
result, err := GetViews("Sample-Page-12-15", dt)
|
||||
result, err := telegraph.GetViews("Sample-Page-12-15", dt)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
t.Run("hour", func(t *testing.T) {
|
||||
dt := time.Date(2000, time.February, 12, 65, 0, 0, 0, time.UTC)
|
||||
result, err := GetViews("Sample-Page-12-15", dt)
|
||||
result, err := telegraph.GetViews("Sample-Page-12-15", dt)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, result)
|
||||
})
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
dt := time.Date(2016, time.December, 31, 0, 0, 0, 0, time.UTC)
|
||||
stats, err := GetViews("Sample-Page-12-15", dt)
|
||||
stats, err := telegraph.GetViews("Sample-Page-12-15", dt)
|
||||
assert.NoError(t, err)
|
||||
if !assert.NotNil(t, stats) {
|
||||
t.FailNow()
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
package telegraph
|
||||
package telegraph_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"gitlab.com/toby3d/telegraph"
|
||||
)
|
||||
|
||||
func TestRevokeAccessToken(t *testing.T) {
|
||||
t.Run("invalid", func(t *testing.T) {
|
||||
var account Account
|
||||
var account telegraph.Account
|
||||
_, err := account.RevokeAccessToken()
|
||||
assert.Error(t, err)
|
||||
})
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
a, err := CreateAccount(Account{
|
||||
a, err := telegraph.CreateAccount(telegraph.Account{
|
||||
ShortName: "Sandbox",
|
||||
AuthorName: "Anonymous",
|
||||
})
|
||||
|
|
|
@ -52,7 +52,7 @@ func makeRequest(path string, payload interface{}) ([]byte, error) {
|
|||
}
|
||||
|
||||
if !r.Ok {
|
||||
return nil, errors.New(r.Error)
|
||||
return nil, errors.New(r.Error) //nolint: goerr113
|
||||
}
|
||||
|
||||
return r.Result, nil
|
||||
|
|
Loading…
Reference in New Issue