-
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.
- Loading branch information
s0s01qp
committed
Jul 21, 2021
1 parent
ead78e1
commit 84ca455
Showing
10 changed files
with
126 additions
and
12 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
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,15 +1,21 @@ | ||
package gin_test | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"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) | ||
w := setupRouterAndGetResponse(t, models.Env, commons.EnvEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
|
||
var env map[string]interface{} | ||
err := json.NewDecoder(w.Body).Decode(&env) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, env) | ||
} |
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,21 @@ | ||
package gin_test | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/sinhashubham95/go-actuator/commons" | ||
) | ||
|
||
func TestHandleHTTPTrace(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.HTTPTrace, commons.HTTPTraceEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
|
||
var traces []*models.HTTPTraceResult | ||
err := json.NewDecoder(w.Body).Decode(&traces) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, traces) | ||
} |
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,20 @@ | ||
package gin_test | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestHandleInfo(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.Info, commons.InfoEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
|
||
var info map[string]interface{} | ||
err := json.NewDecoder(w.Body).Decode(&info) | ||
assert.NoError(t, err) | ||
assert.NotEmpty(t, info) | ||
} |
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,20 @@ | ||
package gin_test | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestHandleMetrics(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.Metrics, commons.MetricsEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
|
||
var metrics *models.MemStats | ||
err := json.NewDecoder(w.Body).Decode(&metrics) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, metrics) | ||
} |
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,14 @@ | ||
package gin_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestHandlePing(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.Ping, commons.PingEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
} |
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,14 @@ | ||
package gin_test | ||
|
||
import ( | ||
"github.com/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestHandleShutdown(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.Shutdown, commons.ShutdownEndpoint) | ||
assert.Equal(t, http.StatusInternalServerError, w.Code) | ||
} |
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/sinhashubham95/go-actuator/commons" | ||
"github.com/sinhashubham95/go-actuator/models" | ||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func TestHandleThreadDump(t *testing.T) { | ||
w := setupRouterAndGetResponse(t, models.ThreadDump, commons.ThreadDumpEndpoint) | ||
assert.Equal(t, http.StatusOK, w.Code) | ||
assert.NotEmpty(t, w.Body.String()) | ||
} |