Fix after updating golangci-lint
v1.43
This commit is contained in:
@ -19,7 +19,7 @@ func TestNewRouterV1WithAuthenticationDisabled(t *testing.T) {
|
||||
configureV1Router(router, nil, nil)
|
||||
|
||||
t.Run("health route is accessible", func(t *testing.T) {
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/health", nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/health", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -30,7 +30,7 @@ func TestNewRouterV1WithAuthenticationDisabled(t *testing.T) {
|
||||
|
||||
t.Run("added route is accessible", func(t *testing.T) {
|
||||
router.HandleFunc("/api/v1/test", mockHTTPHandler)
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/test", nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/test", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -46,7 +46,7 @@ func TestNewRouterV1WithAuthenticationEnabled(t *testing.T) {
|
||||
configureV1Router(router, nil, nil)
|
||||
|
||||
t.Run("health route is accessible", func(t *testing.T) {
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/health", nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/health", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -58,7 +58,7 @@ func TestNewRouterV1WithAuthenticationEnabled(t *testing.T) {
|
||||
t.Run("protected route is not accessible", func(t *testing.T) {
|
||||
// request an available API route that should be guarded by authentication.
|
||||
// (which one, in particular, does not matter here)
|
||||
request, err := http.NewRequest(http.MethodPost, "/api/v1/runners", nil)
|
||||
request, err := http.NewRequest(http.MethodPost, "/api/v1/runners", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ type AuthenticationMiddlewareTestSuite struct {
|
||||
func (s *AuthenticationMiddlewareTestSuite) SetupTest() {
|
||||
correctAuthenticationToken = []byte(testToken)
|
||||
s.recorder = httptest.NewRecorder()
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/test", nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "/api/v1/test", http.NoBody)
|
||||
if err != nil {
|
||||
s.T().Fatal(err)
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func (s *EnvironmentControllerTestSuite) TestList() {
|
||||
})
|
||||
path, err := s.router.Get(listRouteName).URL()
|
||||
s.Require().NoError(err)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Run("with no Environments", func() {
|
||||
@ -63,7 +63,7 @@ func (s *EnvironmentControllerTestSuite) TestList() {
|
||||
query := path.Query()
|
||||
query.Set("fetch", "true")
|
||||
path.RawQuery = query.Encode()
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.router.ServeHTTP(recorder, request)
|
||||
@ -77,7 +77,7 @@ func (s *EnvironmentControllerTestSuite) TestList() {
|
||||
query := path.Query()
|
||||
query.Set("fetch", "YouDecide")
|
||||
path.RawQuery = query.Encode()
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.router.ServeHTTP(recorder, request)
|
||||
@ -114,7 +114,7 @@ func (s *EnvironmentControllerTestSuite) TestGet() {
|
||||
call := s.manager.On("Get", mock.AnythingOfType("dto.EnvironmentID"), mock.AnythingOfType("bool"))
|
||||
path, err := s.router.Get(getRouteName).URL(executionEnvironmentIDKey, tests.DefaultEnvironmentIDAsString)
|
||||
s.Require().NoError(err)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Run("with unknown environment", func() {
|
||||
@ -134,7 +134,7 @@ func (s *EnvironmentControllerTestSuite) TestGet() {
|
||||
query := path.Query()
|
||||
query.Set("fetch", "true")
|
||||
path.RawQuery = query.Encode()
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
call.Run(func(args mock.Arguments) {
|
||||
@ -174,7 +174,7 @@ func (s *EnvironmentControllerTestSuite) TestDelete() {
|
||||
call := s.manager.On("Delete", mock.AnythingOfType("dto.EnvironmentID"))
|
||||
path, err := s.router.Get(deleteRouteName).URL(executionEnvironmentIDKey, tests.DefaultEnvironmentIDAsString)
|
||||
s.Require().NoError(err)
|
||||
request, err := http.NewRequest(http.MethodDelete, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodDelete, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Run("environment not found", func() {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestHealthRoute(t *testing.T) {
|
||||
request, err := http.NewRequest(http.MethodGet, "/health", nil)
|
||||
request, err := http.NewRequest(http.MethodGet, "/health", http.NoBody)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func (s *MiddlewareTestSuite) SetupTest() {
|
||||
s.runnerRequest = func(runnerId string) *http.Request {
|
||||
path, err := s.router.Get("test-runner-id").URL(RunnerIDKey, runnerId)
|
||||
s.Require().NoError(err)
|
||||
request, err := http.NewRequest(http.MethodPost, path.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodPost, path.String(), http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
return request
|
||||
}
|
||||
@ -310,7 +310,7 @@ func (s *DeleteRunnerRouteTestSuite) TestValidRequestReturnsNoContent() {
|
||||
s.runnerManager.On("Return", s.runner).Return(nil)
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
request, err := http.NewRequest(http.MethodDelete, s.path, nil)
|
||||
request, err := http.NewRequest(http.MethodDelete, s.path, http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.router.ServeHTTP(recorder, request)
|
||||
@ -326,7 +326,7 @@ func (s *DeleteRunnerRouteTestSuite) TestReturnInternalServerErrorWhenApiCallToN
|
||||
s.runnerManager.On("Return", s.runner).Return(tests.ErrDefault)
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
request, err := http.NewRequest(http.MethodDelete, s.path, nil)
|
||||
request, err := http.NewRequest(http.MethodDelete, s.path, http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.router.ServeHTTP(recorder, request)
|
||||
@ -341,7 +341,7 @@ func (s *DeleteRunnerRouteTestSuite) TestDeleteInvalidRunnerIdReturnsNotFound()
|
||||
deletePath := deleteURL.String()
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
request, err := http.NewRequest(http.MethodDelete, deletePath, nil)
|
||||
request, err := http.NewRequest(http.MethodDelete, deletePath, http.NoBody)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.router.ServeHTTP(recorder, request)
|
||||
|
@ -38,7 +38,7 @@ type InactivityTimerImplementation struct {
|
||||
state TimerState
|
||||
runner Runner
|
||||
manager Manager
|
||||
sync.Mutex
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func NewInactivityTimer(runner Runner, manager Manager) InactivityTimer {
|
||||
@ -50,8 +50,8 @@ func NewInactivityTimer(runner Runner, manager Manager) InactivityTimer {
|
||||
}
|
||||
|
||||
func (t *InactivityTimerImplementation) SetupTimeout(duration time.Duration) {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
// Stop old timer if present.
|
||||
if t.timer != nil {
|
||||
t.timer.Stop()
|
||||
@ -64,10 +64,10 @@ func (t *InactivityTimerImplementation) SetupTimeout(duration time.Duration) {
|
||||
t.duration = duration
|
||||
|
||||
t.timer = time.AfterFunc(duration, func() {
|
||||
t.Lock()
|
||||
t.mu.Lock()
|
||||
t.state = TimerExpired
|
||||
// The timer must be unlocked here already in order to avoid a deadlock with the call to StopTimout in Manager.Return.
|
||||
t.Unlock()
|
||||
t.mu.Unlock()
|
||||
err := t.manager.Return(t.runner)
|
||||
if err != nil {
|
||||
log.WithError(err).WithField("id", t.runner.ID()).Warn("Returning runner after inactivity caused an error")
|
||||
@ -78,8 +78,8 @@ func (t *InactivityTimerImplementation) SetupTimeout(duration time.Duration) {
|
||||
}
|
||||
|
||||
func (t *InactivityTimerImplementation) ResetTimeout() {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.state != TimerRunning {
|
||||
// The timer has already expired or been stopped. We don't want to restart it.
|
||||
return
|
||||
@ -92,8 +92,8 @@ func (t *InactivityTimerImplementation) ResetTimeout() {
|
||||
}
|
||||
|
||||
func (t *InactivityTimerImplementation) StopTimeout() {
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
if t.state != TimerRunning {
|
||||
return
|
||||
}
|
||||
|
@ -288,13 +288,13 @@ func tarHeader(file dto.File) *tar.Header {
|
||||
return &tar.Header{
|
||||
Typeflag: tar.TypeDir,
|
||||
Name: file.CleanedPath(),
|
||||
Mode: 0755,
|
||||
Mode: 0o755,
|
||||
}
|
||||
} else {
|
||||
return &tar.Header{
|
||||
Typeflag: tar.TypeReg,
|
||||
Name: file.CleanedPath(),
|
||||
Mode: 0744,
|
||||
Mode: 0o744,
|
||||
Size: int64(len(file.Content)),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user