2024-02-05 12:24:56 +00:00
|
|
|
package e2e
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2024-11-18 07:23:41 +00:00
|
|
|
"gitea.pena/PenaSide/customer/internal/models"
|
|
|
|
"gitea.pena/PenaSide/customer/pkg/client"
|
|
|
|
"gitea.pena/PenaSide/customer/tests/helpers"
|
2024-02-05 12:24:56 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2024-05-20 14:29:45 +00:00
|
|
|
func TestPostWalletRspay(t *testing.T) {
|
2024-02-05 12:24:56 +00:00
|
|
|
jwtUtil := helpers.InitializeJWT()
|
|
|
|
|
|
|
|
t.Run("rspay", func(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2024-05-20 14:29:45 +00:00
|
|
|
req := struct {
|
|
|
|
Money float32
|
|
|
|
}{
|
|
|
|
Money: 100,
|
|
|
|
}
|
|
|
|
|
2024-02-05 12:24:56 +00:00
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
token, tokenErr := jwtUtil.Create("6597babdd1ba7e2dbd32d7e3")
|
|
|
|
if isNoError := assert.NoError(t, tokenErr); !isNoError {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
response, err := client.Post[interface{}, models.ResponseErrorHTTP](ctx, &client.RequestSettings{
|
2024-03-11 18:19:39 +00:00
|
|
|
URL: "http://localhost:8082/wallet/rspay",
|
2024-02-05 12:24:56 +00:00
|
|
|
Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)},
|
2024-05-20 14:29:45 +00:00
|
|
|
Body: req,
|
2024-02-05 12:24:56 +00:00
|
|
|
})
|
|
|
|
if isNoError := assert.NoError(t, err); !isNoError {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if isNoRequestError := assert.Nil(t, response.Error); !isNoRequestError {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|