add some recover tests
This commit is contained in:
parent
2508b0fc5e
commit
c2ad4cd3a2
1
tests/e2e/promo_test.go
Normal file
1
tests/e2e/promo_test.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package e2e
|
||||||
@ -7,9 +7,13 @@ import (
|
|||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const BaseUrl = "http://localhost:8080"
|
const (
|
||||||
|
BaseUrl = "http://localhost:8080"
|
||||||
|
ValidSign = "GSiyv5zBITGshqnvYLHKtXE3e4yZjKGvruOVFWuUuj9Nvaps28-Zt6RDq9n47eaNUlay1-nUVld61I3xoAAgCA==65b286c2f13095d96792079d"
|
||||||
|
)
|
||||||
|
|
||||||
// post handler
|
// post handler
|
||||||
func TestRecoveryHandler(t *testing.T) {
|
func TestRecoveryHandler(t *testing.T) {
|
||||||
@ -89,3 +93,28 @@ func TestRecoveryHandler(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get handler
|
// get handler
|
||||||
|
func TestRecoveryLinkHandler(t *testing.T) {
|
||||||
|
client := fiber.AcquireClient()
|
||||||
|
|
||||||
|
t.Run("HandleRecoveryLink_ValidSign", func(t *testing.T) {
|
||||||
|
req := client.Get(BaseUrl + "/recover/" + ValidSign)
|
||||||
|
statusCode, _, errs := req.Bytes()
|
||||||
|
if len(errs) != 0 {
|
||||||
|
assert.NoError(t, errs[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, fiber.StatusOK, statusCode)
|
||||||
|
|
||||||
|
fmt.Println("Recovery link handled successfully")
|
||||||
|
})
|
||||||
|
time.Sleep(15 * time.Minute)
|
||||||
|
t.Run("HandleRecoveryLink_ExpiredSign", func(t *testing.T) {
|
||||||
|
req := client.Get(BaseUrl + "/recover/" + ValidSign)
|
||||||
|
statusCode, _, errs := req.Bytes()
|
||||||
|
if len(errs) != 0 {
|
||||||
|
assert.NoError(t, errs[0])
|
||||||
|
}
|
||||||
|
assert.Equal(t, fiber.StatusNotAcceptable, statusCode)
|
||||||
|
fmt.Println("Recovery link with expired sign handled correctly")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user