mirror of
https://github.com/gotify/server.git
synced 2026-05-06 21:42:07 +08:00
Use golangci-lint
This commit is contained in:
@@ -228,7 +228,6 @@ func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
ctx.JSON(200, withResolvedImage(app))
|
||||
|
||||
}
|
||||
} else {
|
||||
ctx.AbortWithError(404, fmt.Errorf("app with id %d doesn't exists", id))
|
||||
|
||||
@@ -37,8 +37,10 @@ type ApplicationSuite struct {
|
||||
recorder *httptest.ResponseRecorder
|
||||
}
|
||||
|
||||
var originalGenerateApplicationToken func() string
|
||||
var originalGenerateImageName func() string
|
||||
var (
|
||||
originalGenerateApplicationToken func() string
|
||||
originalGenerateImageName func() string
|
||||
)
|
||||
|
||||
func (s *ApplicationSuite) BeforeTest(suiteName, testName string) {
|
||||
originalGenerateApplicationToken = generateApplicationToken
|
||||
@@ -78,6 +80,7 @@ func (s *ApplicationSuite) Test_CreateApplication_mapAllParameters() {
|
||||
assert.Equal(s.T(), expected, app)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) Test_ensureApplicationHasCorrectJsonRepresentation() {
|
||||
actual := &model.Application{
|
||||
ID: 1,
|
||||
@@ -90,6 +93,7 @@ func (s *ApplicationSuite) Test_ensureApplicationHasCorrectJsonRepresentation()
|
||||
}
|
||||
test.JSONEquals(s.T(), actual, `{"id":1,"token":"Aasdasfgeeg","name":"myapp","description":"mydesc", "image": "asd", "internal":true}`)
|
||||
}
|
||||
|
||||
func (s *ApplicationSuite) Test_CreateApplication_expectBadRequestOnEmptyName() {
|
||||
s.db.User(5)
|
||||
|
||||
|
||||
@@ -501,6 +501,7 @@ func (s *MessageSuite) Test_CreateMessage_onQueryData() {
|
||||
assert.Equal(s.T(), 200, s.recorder.Code)
|
||||
assert.Equal(s.T(), uint(1), s.notifiedMessage.ID)
|
||||
}
|
||||
|
||||
func (s *MessageSuite) Test_CreateMessage_onFormData() {
|
||||
auth.RegisterAuthentication(s.ctx, nil, 4, "app-token")
|
||||
s.db.User(4).AppWithToken(99, "app-token")
|
||||
|
||||
@@ -5,9 +5,8 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/gotify/location"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/location"
|
||||
"github.com/gotify/server/v2/auth"
|
||||
"github.com/gotify/server/v2/model"
|
||||
"github.com/gotify/server/v2/plugin"
|
||||
|
||||
@@ -8,8 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gotify/server/v2/mode"
|
||||
"github.com/gotify/server/v2/model"
|
||||
"github.com/gotify/server/v2/plugin"
|
||||
@@ -17,11 +16,9 @@ import (
|
||||
"github.com/gotify/server/v2/plugin/testing/mock"
|
||||
"github.com/gotify/server/v2/test"
|
||||
"github.com/gotify/server/v2/test/testdb"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func TestPluginSuite(t *testing.T) {
|
||||
@@ -101,7 +98,6 @@ func (s *PluginSuite) Test_GetPlugins() {
|
||||
}
|
||||
|
||||
func (s *PluginSuite) Test_EnableDisablePlugin() {
|
||||
|
||||
{
|
||||
test.WithUser(s.ctx, 1)
|
||||
|
||||
@@ -161,7 +157,6 @@ func (s *PluginSuite) Test_EnableDisablePlugin() {
|
||||
}
|
||||
s.resetRecorder()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *PluginSuite) Test_EnableDisablePlugin_EnableReturnsError_expect500() {
|
||||
@@ -239,7 +234,6 @@ func (s *PluginSuite) Test_EnableDisablePlugin_incorrectUser_expectNotFound() {
|
||||
}
|
||||
s.resetRecorder()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *PluginSuite) Test_EnableDisablePlugin_nonExistPlugin_expectNotFound() {
|
||||
@@ -264,7 +258,6 @@ func (s *PluginSuite) Test_EnableDisablePlugin_nonExistPlugin_expectNotFound() {
|
||||
assert.Equal(s.T(), 404, s.recorder.Code)
|
||||
s.resetRecorder()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *PluginSuite) Test_EnableDisablePlugin_danglingConf_expectNotFound() {
|
||||
|
||||
@@ -77,7 +77,7 @@ func (c *client) startReading(pongWait time.Duration) {
|
||||
// startWriteHandler starts the write loop. The method has the following tasks:
|
||||
// * ping the client in the interval provided as parameter
|
||||
// * write messages send by the channel to the client
|
||||
// * on errors exit the loop
|
||||
// * on errors exit the loop.
|
||||
func (c *client) startWriteHandler(pingPeriod time.Duration) {
|
||||
pingTicker := time.NewTicker(pingPeriod)
|
||||
defer func() {
|
||||
|
||||
@@ -166,7 +166,7 @@ func isAllowedOrigin(r *http.Request, allowedOrigins []*regexp.Regexp) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if strings.ToLower(u.Host) == strings.ToLower(r.Host) {
|
||||
if strings.EqualFold(u.Host, r.Host) {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -484,7 +484,6 @@ func startReading(client *testingClient) {
|
||||
go func() {
|
||||
for {
|
||||
_, payload, err := client.conn.ReadMessage()
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (a *UserAPI) CreateUser(ctx *gin.Context) {
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) GetUserByID(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
user, err := a.DB.GetUserByID(uint(id))
|
||||
user, err := a.DB.GetUserByID(id)
|
||||
if success := successOrAbort(ctx, 500, err); !success {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ func (s *UserSuite) BeforeTest(suiteName, testName string) {
|
||||
})
|
||||
s.a = &UserAPI{DB: s.db, UserChangeNotifier: s.notifier}
|
||||
}
|
||||
|
||||
func (s *UserSuite) AfterTest(suiteName, testName string) {
|
||||
s.db.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user