summaryrefslogtreecommitdiff
diff options
authorPawel Stolowski <stolowski@gmail.com>2016-11-21 11:53:43 +0100
committerPawel Stolowski <stolowski@gmail.com>2016-11-21 11:53:43 +0100
commite09e311f90de171c6154a4dcc24557d32731a875 (patch)
treecacd98be9bc962d17d93bb905d7165c4b7940c52
parentfaf85d25ab649b6092df00a4ba7b77d9abb84450 (diff)
Test for 500 error on 1st callstore-retry-details
-rw-r--r--store/store_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/store/store_test.go b/store/store_test.go
index 07753a287a..ab15d7047a 100644
--- a/store/store_test.go
+++ b/store/store_test.go
@@ -1344,6 +1344,38 @@ func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryDetails500(c *C) {
c.Assert(n, Equals, 6)
}
+func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryDetails500once(c *C) {
+ var n = 0
+ mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ n++
+ if n > 1 {
+ w.Header().Set("X-Suggested-Currency", "GBP")
+ w.WriteHeader(http.StatusOK)
+ io.WriteString(w, MockDetailsJSON)
+ } else {
+ w.WriteHeader(http.StatusInternalServerError)
+ }
+ }))
+
+ c.Assert(mockServer, NotNil)
+ defer mockServer.Close()
+
+ detailsURI, err := url.Parse(mockServer.URL + "/details/")
+ c.Assert(err, IsNil)
+ cfg := Config{
+ DetailsURI: detailsURI,
+ }
+ authContext := &testAuthContext{c: c, device: t.device}
+ repo := New(&cfg, authContext)
+ c.Assert(repo, NotNil)
+
+ // the actual test
+ result, err := repo.Snap("hello-world", "edge", true, snap.R(0), nil)
+ c.Assert(err, IsNil)
+ c.Check(result.Name(), Equals, "hello-world")
+ c.Assert(n, Equals, 2)
+}
+
func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryNonDefaults(c *C) {
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
storeID := r.Header.Get("X-Ubuntu-Store")