Skip to content

Commit

Permalink
added test cases and fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
s0s01qp committed Jul 21, 2021
1 parent db6b7a3 commit 6466ef7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions controllers/fasthttp/commons_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ import (
"github.com/sinhashubham95/go-actuator/models"
"github.com/stretchr/testify/assert"
"github.com/valyala/fasthttp"
"math/rand"
"net/http"
"sync"
"testing"
)

var encodeJSON = commons.EncodeJSON
var getThreadDump = core.GetThreadDump

var portMu sync.Mutex
var port = 1001

func getRandomPortNumber() int {
return rand.Intn(9800) + 100
portMu.Lock()
defer portMu.Unlock()
port += 10
return port
}

func setupFastHTTPHandlersAndGetResponse(t *testing.T, endpoint int, path string) *http.Response {
Expand Down
10 changes: 8 additions & 2 deletions core/httptrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import (
"github.com/sinhashubham95/go-actuator/models"
"github.com/stretchr/testify/assert"
"github.com/valyala/fasthttp"
"math/rand"
"net/http"
"net/http/httptest"
"sync"
"testing"

"github.com/sinhashubham95/go-actuator/core"
)

var portMu sync.Mutex
var port = 2001

func TestGetHTTPTrace(t *testing.T) {
assert.Empty(t, core.GetHTTPTrace())
}
Expand Down Expand Up @@ -104,7 +107,10 @@ func TestForMoreThanThresholdRequests(t *testing.T) {
}

func getRandomPortNumber() int {
return rand.Intn(9800) + 100
portMu.Lock()
defer portMu.Unlock()
port += 10
return port
}

func setupGINRouter() *gin.Engine {
Expand Down

0 comments on commit 6466ef7

Please sign in to comment.