summaryrefslogtreecommitdiff
diff options
authorPawel Stolowski <stolowski@gmail.com>2016-11-21 16:16:07 +0100
committerPawel Stolowski <stolowski@gmail.com>2016-11-21 16:16:07 +0100
commita8c97951f380719df159a1351b3aa7a78c274b96 (patch)
tree1ad78aaab32300b587131daef4eaad53b630a95b
parent1d73a6b63e385f2a4c9c3859f87c7784f8427126 (diff)
Test for 500 errorstore-retry-buy
-rw-r--r--store/store_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/store/store_test.go b/store/store_test.go
index 316454f664..10b83e7aec 100644
--- a/store/store_test.go
+++ b/store/store_test.go
@@ -2944,6 +2944,43 @@ var buyTests = []struct {
},
}
+func (t *remoteRepoTestSuite) TestUbuntuStoreBuy500(c *C) {
+ n := 0
+ mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ n++
+ w.WriteHeader(http.StatusInternalServerError)
+ }))
+ c.Assert(mockServer, NotNil)
+ defer mockServer.Close()
+
+ mockPurchasesServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ }))
+
+ detailsURI, err := url.Parse(mockServer.URL)
+ c.Assert(err, IsNil)
+ ordersURI, err := url.Parse(mockPurchasesServer.URL + ordersPath)
+ c.Assert(err, IsNil)
+ customersMeURI, err := url.Parse(mockPurchasesServer.URL + customersMePath)
+ c.Assert(err, IsNil)
+
+ authContext := &testAuthContext{c: c, device: t.device, user: t.user}
+ cfg := Config{
+ CustomersMeURI: customersMeURI,
+ DetailsURI: detailsURI,
+ OrdersURI: ordersURI,
+ }
+ repo := New(&cfg, authContext)
+ c.Assert(repo, NotNil)
+
+ buyOptions := &BuyOptions{
+ SnapID: helloWorldSnapID,
+ Currency: "USD",
+ Price: 1,
+ }
+ _, err = repo.Buy(buyOptions, t.user)
+ c.Assert(err, NotNil)
+}
+
func (t *remoteRepoTestSuite) TestUbuntuStoreBuy(c *C) {
for _, test := range buyTests {
searchServerCalled := false