stripe / stripe-mock

stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's testmode to make test suites integrating with Stripe faster and less brittle.
MIT License
1.4k stars 110 forks source link

Is it possible to use stripe-mock with uber-go/mock? #1029

Open kakuiho opened 1 day ago

kakuiho commented 1 day ago

Is it possible to use stripe-mock with uber-go/mock?

pseudocode

    // setup envs
    ctrl := gomock.NewController(t)
    stripeImpl := stripe.NewImplMock(ctrl)
    stripe.UseImpl(stripeImpl)

    // make up something we want 
    mockIter := ...
    stripeImpl.EXPECT().PriceList(xxx).Return(mockIter, nil)
    // or 
    // stripePriceImpl.EXPECT().List(xxx).Return(mockIter, nil)

    // testing 
    params := &stripe.PriceListParams{
        LookupKeys: stripe.StringSlice([]string{LookupKey}),
    }
    rsIter := price.List(params)
    // ...
seanzhang-stripe commented 1 day ago

stripe-mock is a mock HTTP server and I'm not sure if uber-go/mock can interact with a mock HTTP server. Anyway, stripe-go utilizes stripe-mock for testing, you can check the test code here to see how to use it.