treasurer/cmd/mock/main.go
2024-12-16 16:47:40 +03:00

46 lines
1.1 KiB
Go

package main
import (
"fmt"
"log"
"github.com/walkerus/go-wiremock"
"gitea.pena/PenaSide/treasurer/internal/models/yandex"
)
func main() {
mockClient := wiremock.NewClient("http://localhost:8080")
if err := mockClient.StubFor(wiremock.
Post(wiremock.URLPathEqualTo("/payments")).
WillReturnJSON(
&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",
},
},
map[string]string{"Content-Type": "application/json"},
200,
).
AtPriority(1),
); err != nil {
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)
}
fmt.Println(isVerified)
}