generated from PenaSide/GolangTemplate
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package e2e
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/stretchr/testify/assert"
|
|
"gitea.pena/PenaSide/customer/internal/models"
|
|
"gitea.pena/PenaSide/customer/pkg/client"
|
|
"gitea.pena/PenaSide/customer/tests/helpers"
|
|
"testing"
|
|
)
|
|
|
|
func TestPostWalletRspay(t *testing.T) {
|
|
jwtUtil := helpers.InitializeJWT()
|
|
|
|
t.Run("rspay", func(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
req := struct {
|
|
Money float32
|
|
}{
|
|
Money: 100,
|
|
}
|
|
|
|
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{
|
|
URL: "http://localhost:8082/wallet/rspay",
|
|
Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)},
|
|
Body: req,
|
|
})
|
|
if isNoError := assert.NoError(t, err); !isNoError {
|
|
return
|
|
}
|
|
if isNoRequestError := assert.Nil(t, response.Error); !isNoRequestError {
|
|
return
|
|
}
|
|
})
|
|
})
|
|
|
|
}
|