Skip to content

Commit 2c4008b

Browse files
committed
Ping controller
1 parent 5ab484d commit 2c4008b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package polo
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/gin-gonic/gin"
7+
)
8+
9+
const (
10+
polo = "polo"
11+
)
12+
13+
func Marco(c *gin.Context) {
14+
c.String(http.StatusOK, polo)
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package polo
2+
3+
import (
4+
"net/http"
5+
"net/http/httptest"
6+
"testing"
7+
8+
"github.com/aditya43/golang_github_microservice/src/api/utils/test_utils"
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestConstants(t *testing.T) {
13+
assert.EqualValues(t, "polo", polo)
14+
}
15+
16+
func TestPolo(t *testing.T) {
17+
response := httptest.NewRecorder()
18+
request := httptest.NewRequest(http.MethodGet, "/marco", nil)
19+
c := test_utils.GetMockedContext(request, response)
20+
21+
Marco(c)
22+
23+
assert.EqualValues(t, http.StatusOK, response.Code)
24+
assert.EqualValues(t, "polo", response.Body.String())
25+
}

0 commit comments

Comments
 (0)