mirror of
https://gitea.com/action-examples/Go.git
synced 2026-03-27 08:30:06 +00:00
chore: update Go version and add dependencies
- Update the Go version from `1.21.2` to `1.21` - Add `github.com/stretchr/testify` as a required dependency - Add `github.com/davecgh/go-spew` as an indirect dependency - Add `github.com/pmezard/go-difflib` as an indirect dependency - Add a new test file `router/router_test.go` - Implement a test for the `PingRoute` function in `router/router_test.go` Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
20
router/router_test.go
Normal file
20
router/router_test.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestPingRoute(t *testing.T) {
|
||||
router := New()
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
req, _ := http.NewRequest("GET", "/ping", nil)
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
assert.Equal(t, 200, w.Code)
|
||||
assert.Equal(t, "pong", w.Body.String())
|
||||
}
|
||||
Reference in New Issue
Block a user