func (s *SnapTestSuite) TestUbuntuStoreRepositoryAliasSearch(c *C) { mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, MockAliasSearchJSON) })) c.Assert(mockServer, NotNil) defer mockServer.Close() var err error storeSearchURI, err = url.Parse(mockServer.URL) c.Assert(err, IsNil) snap := NewUbuntuStoreSnapRepository() c.Assert(snap, NotNil) results, err := snap.Search("hello-world") c.Assert(err, IsNil) c.Assert(results, HasLen, 1) c.Assert(results["hello-world"], NotNil) parts := results["hello-world"].Parts c.Assert(parts, HasLen, 2) c.Check(parts[0].Name(), Equals, "hello-world") c.Check(parts[1].Name(), Equals, "hello-world") c.Check(parts[0].Origin(), Equals, "canonical") c.Check(parts[1].Origin(), Equals, "jdstrand") c.Check(parts[0].Version(), Equals, "1.0.8") c.Check(parts[1].Version(), Equals, "1.4") c.Check(parts[0].Description(), Equals, "hello-world") c.Check(parts[1].Description(), Equals, "hello-world") alias := results["hello-world"].Alias c.Assert(alias, DeepEquals, parts[0]) }
func (s *SnapTestSuite) TestUbuntuStoreRepositorySearch(c *C) { mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, MockSearchJSON) })) c.Assert(mockServer, NotNil) defer mockServer.Close() var err error storeSearchURI, err = url.Parse(mockServer.URL) c.Assert(err, IsNil) snap := NewUbuntuStoreSnapRepository() c.Assert(snap, NotNil) results, err := snap.Search(funkyAppName) c.Assert(err, IsNil) c.Assert(results, HasLen, 1) c.Assert(results[funkyAppName], NotNil) parts := results[funkyAppName].Parts c.Assert(parts, HasLen, 1) c.Check(parts[0].Name(), Equals, funkyAppName) c.Check(parts[0].Origin(), Equals, funkyAppOrigin) c.Check(parts[0].Version(), Equals, "42") c.Check(parts[0].Description(), Equals, "Returns for store credit only.") }