2023-06-13 13:22:51 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-06-19 17:29:15 +00:00
|
|
|
"fmt"
|
2023-06-13 13:22:51 +00:00
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/walkerus/go-wiremock"
|
2024-12-16 13:47:40 +00:00
|
|
|
"gitea.pena/PenaSide/treasurer/internal/models/yandex"
|
2023-06-13 13:22:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-06-19 17:29:15 +00:00
|
|
|
mockClient := wiremock.NewClient("http://localhost:8080")
|
2023-06-13 13:22:51 +00:00
|
|
|
|
2023-06-19 17:29:15 +00:00
|
|
|
if err := mockClient.StubFor(wiremock.
|
2023-06-13 13:22:51 +00:00
|
|
|
Post(wiremock.URLPathEqualTo("/payments")).
|
|
|
|
WillReturnJSON(
|
2023-06-19 17:29:15 +00:00
|
|
|
&yandex.Payment{
|
|
|
|
ID: "f32d71f4-214b-464b-94bb-f7b4d5299af0",
|
|
|
|
Status: yandex.PaymentStatusPending,
|
|
|
|
Amount: yandex.Amount{
|
|
|
|
Value: "150.00",
|
|
|
|
Currency: "RUB",
|
|
|
|
},
|
|
|
|
Confirmation: &yandex.ConfirmationRedirect{
|
|
|
|
Type: yandex.ConfirmationTypeRedirect,
|
|
|
|
ConfirmationURL: "https://yandex-redirect-url.com",
|
|
|
|
},
|
|
|
|
},
|
2023-06-13 13:22:51 +00:00
|
|
|
map[string]string{"Content-Type": "application/json"},
|
|
|
|
200,
|
|
|
|
).
|
|
|
|
AtPriority(1),
|
|
|
|
); err != nil {
|
2023-06-19 17:29:15 +00:00
|
|
|
log.Fatal("failed to stub bankcard payment: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
request := wiremock.NewRequest("post", wiremock.URLPathEqualTo("/payments"))
|
|
|
|
|
|
|
|
isVerified, err := mockClient.Verify(request, 0)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("failed to verify /payments request: %w", err)
|
2023-06-13 13:22:51 +00:00
|
|
|
}
|
|
|
|
|
2023-06-19 17:29:15 +00:00
|
|
|
fmt.Println(isVerified)
|
2023-06-13 13:22:51 +00:00
|
|
|
}
|