-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test cases and go vet fixes renaming packages and file names to…
… lower case
- Loading branch information
s0s01qp
committed
Jul 21, 2021
1 parent
3df77fc
commit ead78e1
Showing
33 changed files
with
196 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/fastHTTP/httpTrace.go → controllers/fasthttp/httptrace.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/fastHTTP/metrics.go → controllers/fasthttp/metrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/models" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/fastHTTP/shutdown.go → controllers/fasthttp/shutdown.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/fastHTTP/threadDump.go → controllers/fasthttp/threaddump.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fastHTTP | ||
package fasthttp | ||
|
||
import ( | ||
"github.com/valyala/fasthttp" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package gin_test | ||
|
||
import ( | ||
"github.com/gin-gonic/gin" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
) | ||
|
||
func setupRouterAndGetResponse(t *testing.T, endpoint string, handler gin.HandlerFunc) *httptest.ResponseRecorder { | ||
router := gin.Default() | ||
router.GET(endpoint, handler) | ||
|
||
request, err := http.NewRequest(http.MethodGet, endpoint, nil) | ||
assert.NoError(t, err) | ||
|
||
w := httptest.NewRecorder() | ||
router.ServeHTTP(w, request) | ||
|
||
return w | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package gin_test | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/sinhashubham95/go-actuator/commons" | ||
ginControllers "github.com/sinhashubham95/go-actuator/controllers/gin" | ||
) | ||
|
||
func TestHandleEnv(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, commons.EnvEndpoint, ginControllers.HandleEnv) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/netHTTP/httpTrace.go → controllers/nethttp/httptrace.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/netHTTP/metrics.go → controllers/nethttp/metrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/netHTTP/shutdown.go → controllers/nethttp/shutdown.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
2 changes: 1 addition & 1 deletion
2
controllers/netHTTP/threadDump.go → controllers/nethttp/threaddump.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package netHTTP | ||
package nethttp | ||
|
||
import ( | ||
"net/http" | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package core_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/core" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestGetInfo(t *testing.T) { | ||
info := core.GetInfo() | ||
assert.NotEmpty(t, info[commons.Application]) | ||
assert.NotEmpty(t, info[commons.Git]) | ||
assert.NotEmpty(t, info[commons.Runtime]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package core_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/core" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestGetMetrics(t *testing.T) { | ||
assert.NotNil(t, core.GetMetrics()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package core_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/core" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestShutdown(t *testing.T) { | ||
defer func() { | ||
r := recover() | ||
assert.NotNil(t, r) | ||
}() | ||
core.Shutdown() | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package core_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/core" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestGetThreadDump(t *testing.T) { | ||
dump, err := core.GetThreadDump() | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, string(dump)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package flags_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/flags" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestEnv(t *testing.T) { | ||
assert.Equal(t, commons.EnvDefaultValue, flags.Env()) | ||
} | ||
|
||
func TestName(t *testing.T) { | ||
assert.Equal(t, commons.NameDefaultValue, flags.Name()) | ||
} | ||
|
||
func TestPort(t *testing.T) { | ||
assert.Equal(t, commons.PortDefaultValue, flags.Port()) | ||
} | ||
|
||
func TestVersion(t *testing.T) { | ||
assert.Equal(t, commons.VersionDefaultValue, flags.Version()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package models_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestConfigValidateInvalidPrefix(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
if err, ok := r.(error); ok { | ||
assert.Error(t, err) | ||
assert.Equal(t, "invalid prefix provided", err.Error()) | ||
} | ||
} | ||
}() | ||
config := &models.Config{ | ||
Prefix: "postgres://user:abc{[email protected]:5432/db?sslmode=require", | ||
} | ||
config.Validate() | ||
} | ||
|
||
func TestConfigValidateInvalidEndpoints(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
if err, ok := r.(error); ok { | ||
assert.Error(t, err) | ||
assert.Equal(t, "invalid endpoint 999 provided", err.Error()) | ||
} | ||
} | ||
}() | ||
config := &models.Config{ | ||
Endpoints: []int{999}, | ||
} | ||
config.Validate() | ||
} | ||
|
||
func TestConfigDefault(t *testing.T) { | ||
config := &models.Config{} | ||
config.Default() | ||
assert.Equal(t, commons.DefaultActuatorPrefix, config.Prefix) | ||
assert.Equal(t, models.Endpoints, config.Endpoints) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package models_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestIsValidEndpoint(t *testing.T) { | ||
assert.True(t, models.IsValidEndpoint(models.Env)) | ||
assert.True(t, models.IsValidEndpoint(models.HTTPTrace)) | ||
assert.True(t, models.IsValidEndpoint(models.Info)) | ||
assert.True(t, models.IsValidEndpoint(models.Metrics)) | ||
assert.True(t, models.IsValidEndpoint(models.Ping)) | ||
assert.True(t, models.IsValidEndpoint(models.Shutdown)) | ||
assert.True(t, models.IsValidEndpoint(models.ThreadDump)) | ||
} |