customer/tests/e2e/sendReport_test.go

39 lines
1.0 KiB
Go
Raw Normal View History

2024-02-01 19:46:20 +00:00
package e2e_test
import (
"context"
"fmt"
"net/http"
"testing"
"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-01 19:46:20 +00:00
)
// todo thinking
func TestSendReport(t *testing.T) {
jwtUtil := helpers.InitializeJWT()
t.Run("Send Report", func(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
2024-02-02 09:56:33 +00:00
historyID := "65bb62f606b4708f85c7d152"
2024-02-01 19:46:20 +00:00
2024-02-02 09:56:33 +00:00
token, tokenErr := jwtUtil.Create("64e5d9830fcca0596d82c0c7")
2024-02-01 19:46:20 +00:00
assert.NoError(t, tokenErr)
responseSendReport, errSendReport := client.Post[interface{}, models.ResponseErrorHTTP](ctx, &client.RequestSettings{
2024-03-11 18:19:39 +00:00
URL: "http://localhost:8082/sendReport",
2024-02-01 19:46:20 +00:00
Headers: map[string]string{"Authorization": fmt.Sprintf("Bearer %s", token)},
Body: map[string]interface{}{"id": historyID},
})
assert.NoError(t, errSendReport)
assert.Nil(t, responseSendReport.Error)
assert.Equal(t, http.StatusOK, responseSendReport.StatusCode)
})
}