treasurer/cmd/mock/main.go
2023-06-13 13:22:51 +00:00

41 lines
841 B
Go

package main
import (
"log"
"github.com/walkerus/go-wiremock"
"penahub.gitlab.yandexcloud.net/external/treasurer/internal/models/yandex"
)
func main() {
mocklient := wiremock.NewClient("http://localhost:8000")
if err := mocklient.StubFor(wiremock.
Post(wiremock.URLPathEqualTo("/payments")).
WithBodyPattern(wiremock.EqualToJson(`{
"amount": {
"value": "150.00",
"currency": "RUB"
},
"payment_method_data": {
"type": "bank_card"
},
"confirmation": {
"type": "redirect",
"enforce": true,
"locale": "ru_RU",
"return_url": "https://www.example.com/return_url"
},
}`)).
WillReturnJSON(
&yandex.Payment{},
map[string]string{"Content-Type": "application/json"},
200,
).
AtPriority(1),
); err != nil {
log.Fatal("failed to stub <create phone payments>: %w", err)
}
}