本文整理汇总了Golang中github.com/juju/charm.MustParseURL函数的典型用法代码示例。如果您正苦于以下问题:Golang MustParseURL函数的具体用法?Golang MustParseURL怎么用?Golang MustParseURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MustParseURL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestRedundantUpdate
func (s *StoreSuite) TestRedundantUpdate(c *gc.C) {
urlA := charm.MustParseURL("cs:oneiric/wordpress-a")
urlB := charm.MustParseURL("cs:oneiric/wordpress-b")
urls := []*charm.URL{urlA, urlB}
pub, err := s.store.CharmPublisher(urls, "digest-0")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 0)
err = pub.Publish(&FakeCharmDir{})
c.Assert(err, gc.IsNil)
// All charms are already on digest-0.
pub, err = s.store.CharmPublisher(urls, "digest-0")
c.Assert(err, gc.ErrorMatches, "charm is up-to-date")
c.Assert(err, gc.Equals, charmstore.ErrRedundantUpdate)
c.Assert(pub, gc.IsNil)
// Now add a second revision just for wordpress-b.
pub, err = s.store.CharmPublisher(urls[1:], "digest-1")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 1)
err = pub.Publish(&FakeCharmDir{})
c.Assert(err, gc.IsNil)
// Same digest bumps revision because one of them was old.
pub, err = s.store.CharmPublisher(urls, "digest-1")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 2)
err = pub.Publish(&FakeCharmDir{})
c.Assert(err, gc.IsNil)
}
开发者ID:rogpeppe,项目名称:charmstore,代码行数:31,代码来源:store_test.go
示例2: TestLockUpdatesExpires
func (s *StoreSuite) TestLockUpdatesExpires(c *gc.C) {
urlA := charm.MustParseURL("cs:oneiric/wordpress-a")
urlB := charm.MustParseURL("cs:oneiric/wordpress-b")
urls := []*charm.URL{urlA, urlB}
// Initiate an update of B only to force a partial conflict.
lock1, err := s.store.LockUpdates(urls[1:])
c.Assert(err, gc.IsNil)
// Hack time to force an expiration.
locks := s.Session.DB("juju").C("locks")
selector := bson.M{"_id": urlB.String()}
update := bson.M{"time": bson.Now().Add(-charmstore.UpdateTimeout - 10e9)}
err = locks.Update(selector, update)
c.Check(err, gc.IsNil)
// Works due to expiration of previous lock.
lock2, err := s.store.LockUpdates(urls)
c.Assert(err, gc.IsNil)
defer lock2.Unlock()
// The expired lock was forcefully killed. Unlocking it must
// not interfere with lock2 which is still alive.
lock1.Unlock()
// The above statement was a NOOP and lock2 is still in effect,
// so attempting another lock must necessarily fail.
lock3, err := s.store.LockUpdates(urls)
c.Check(err, gc.Equals, charmstore.ErrUpdateConflict)
c.Check(lock3, gc.IsNil)
}
开发者ID:rogpeppe,项目名称:charmstore,代码行数:31,代码来源:store_test.go
示例3: TestBranchLocation
func (s *StoreSuite) TestBranchLocation(c *gc.C) {
charmURL := charm.MustParseURL("cs:series/name")
location := s.store.BranchLocation(charmURL)
c.Assert(location, gc.Equals, "lp:charms/series/name")
charmURL = charm.MustParseURL("cs:~user/series/name")
location = s.store.BranchLocation(charmURL)
c.Assert(location, gc.Equals, "lp:~user/charms/series/name/trunk")
}
开发者ID:bz2,项目名称:charm,代码行数:9,代码来源:repo_test.go
示例4: TestGetCacheImplicitRevision
func (s *StoreSuite) TestGetCacheImplicitRevision(c *gc.C) {
base := "cs:series/good"
charmURL := charm.MustParseURL(base)
revCharmURL := charm.MustParseURL(base + "-23")
ch, err := s.store.Get(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(ch, gc.NotNil)
c.Assert(s.server.Downloads, gc.DeepEquals, []*charm.URL{revCharmURL})
s.assertCached(c, charmURL)
s.assertCached(c, revCharmURL)
}
开发者ID:bz2,项目名称:charm,代码行数:11,代码来源:repo_test.go
示例5: TestPublishCharmDistro
func (s *StoreSuite) TestPublishCharmDistro(c *gc.C) {
branch := s.dummyBranch(c, "~joe/charms/oneiric/dummy/trunk")
// The Distro call will look for bare /charms, first.
gitjujutesting.Server.Response(200, jsonType, []byte("{}"))
// And then it picks up the tips.
data := fmt.Sprintf(`[`+
`["file://%s", "rev1", ["oneiric", "precise"]],`+
`["file://%s", "%s", []],`+
`["file:///non-existent/~jeff/charms/precise/bad/trunk", "rev2", []],`+
`["file:///non-existent/~jeff/charms/precise/bad/skip-me", "rev3", []]`+
`]`,
branch.path(), branch.path(), branch.digest())
gitjujutesting.Server.Response(200, jsonType, []byte(data))
apiBase := lpad.APIBase(gitjujutesting.Server.URL)
err := charmstore.PublishCharmsDistro(s.store, apiBase)
// Should have a single failure from the trunk branch that doesn't
// exist. The redundant update with the known digest should be
// ignored, and skip-me isn't a supported branch name so it's
// ignored as well.
c.Assert(err, gc.ErrorMatches, `1 branch\(es\) failed to be published`)
berr := err.(charmstore.PublishBranchErrors)[0]
c.Assert(berr.URL, gc.Equals, "file:///non-existent/~jeff/charms/precise/bad/trunk")
c.Assert(berr.Err, gc.ErrorMatches, "(?s).*bzr: ERROR: Not a branch.*")
for _, url := range []string{"cs:oneiric/dummy", "cs:precise/dummy-0", "cs:~joe/oneiric/dummy-0"} {
dummy, err := s.store.CharmInfo(charm.MustParseURL(url))
c.Assert(err, gc.IsNil)
c.Assert(dummy.Meta().Name, gc.Equals, "dummy")
}
// The known digest should have been ignored, so revision is still at 0.
_, err = s.store.CharmInfo(charm.MustParseURL("cs:~joe/oneiric/dummy-1"))
c.Assert(err, gc.Equals, charmstore.ErrNotFound)
// bare /charms lookup
req := gitjujutesting.Server.WaitRequest()
c.Assert(req.Method, gc.Equals, "GET")
c.Assert(req.URL.Path, gc.Equals, "/charms")
// tips request
req = gitjujutesting.Server.WaitRequest()
c.Assert(req.Method, gc.Equals, "GET")
c.Assert(req.URL.Path, gc.Equals, "/charms")
c.Assert(req.Form["ws.op"], gc.DeepEquals, []string{"getBranchTips"})
c.Assert(req.Form["since"], gc.IsNil)
// Request must be signed by juju.
c.Assert(req.Header.Get("Authorization"), gc.Matches, `.*oauth_consumer_key="juju".*`)
}
开发者ID:rogpeppe,项目名称:charmstore,代码行数:53,代码来源:lpad_test.go
示例6: TestMissingRepo
func (s *LocalRepoSuite) TestMissingRepo(c *gc.C) {
c.Assert(os.RemoveAll(s.repo.Path), gc.IsNil)
_, err := charm.Latest(s.repo, charm.MustParseURL("local:quantal/zebra"))
c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
_, err = s.repo.Get(charm.MustParseURL("local:quantal/zebra"))
c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
c.Assert(ioutil.WriteFile(s.repo.Path, nil, 0666), gc.IsNil)
_, err = charm.Latest(s.repo, charm.MustParseURL("local:quantal/zebra"))
c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
_, err = s.repo.Get(charm.MustParseURL("local:quantal/zebra"))
c.Assert(err, gc.ErrorMatches, `no repository found at ".*"`)
}
开发者ID:bz2,项目名称:charm,代码行数:12,代码来源:repo_test.go
示例7: TestMustParseURL
func (s *URLSuite) TestMustParseURL(c *gc.C) {
url := charm.MustParseURL("cs:series/name")
c.Assert(url, gc.DeepEquals,
&charm.URL{Reference: charm.Reference{"cs", "", "name", -1}, Series: "series"})
f := func() { charm.MustParseURL("local:@@/name") }
c.Assert(f, gc.PanicMatches, "charm URL has invalid series: .*")
f = func() { charm.MustParseURL("cs:~user") }
c.Assert(f, gc.PanicMatches, "charm URL without charm name: .*")
f = func() { charm.MustParseURL("cs:~user") }
c.Assert(f, gc.PanicMatches, "charm URL without charm name: .*")
f = func() { charm.MustParseURL("cs:name") }
c.Assert(f, gc.PanicMatches, "charm url series is not resolved")
}
开发者ID:howbazaar,项目名称:charm,代码行数:13,代码来源:url_test.go
示例8: TestLatest
func (s *StoreSuite) TestLatest(c *gc.C) {
urls := []*charm.URL{
charm.MustParseURL("cs:series/good"),
charm.MustParseURL("cs:series/good-2"),
charm.MustParseURL("cs:series/good-99"),
}
revInfo, err := s.store.Latest(urls...)
c.Assert(err, gc.IsNil)
c.Assert(revInfo, gc.DeepEquals, []charm.CharmRevision{
{23, "c89d9b522cebbd68061048ed2910180e1b63b6afaa373d1fe1c47ff9970be126", nil},
{23, "c89d9b522cebbd68061048ed2910180e1b63b6afaa373d1fe1c47ff9970be126", nil},
{23, "c89d9b522cebbd68061048ed2910180e1b63b6afaa373d1fe1c47ff9970be126", nil},
})
}
开发者ID:bz2,项目名称:charm,代码行数:14,代码来源:repo_test.go
示例9: TestInfo
func (s *StoreSuite) TestInfo(c *gc.C) {
charmURLs := []charm.Location{
charm.MustParseURL("cs:series/good"),
charm.MustParseURL("cs:series/better"),
charm.MustParseURL("cs:series/best"),
}
infos, err := s.store.Info(charmURLs...)
c.Assert(err, gc.IsNil)
c.Assert(infos, gc.HasLen, 3)
expected := []int{23, 24, 25}
for i, info := range infos {
c.Assert(info.Errors, gc.IsNil)
c.Assert(info.Revision, gc.Equals, expected[i])
}
}
开发者ID:bz2,项目名称:charm,代码行数:15,代码来源:repo_test.go
示例10: TestGetBadCache
func (s *StoreSuite) TestGetBadCache(c *gc.C) {
c.Assert(os.Mkdir(filepath.Join(charm.CacheDir, "cache"), 0777), gc.IsNil)
base := "cs:series/good"
charmURL := charm.MustParseURL(base)
revCharmURL := charm.MustParseURL(base + "-23")
name := charm.Quote(revCharmURL.String()) + ".charm"
err := ioutil.WriteFile(filepath.Join(charm.CacheDir, "cache", name), nil, 0666)
c.Assert(err, gc.IsNil)
ch, err := s.store.Get(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(ch, gc.NotNil)
c.Assert(s.server.Downloads, gc.DeepEquals, []*charm.URL{revCharmURL})
s.assertCached(c, charmURL)
s.assertCached(c, revCharmURL)
}
开发者ID:bz2,项目名称:charm,代码行数:15,代码来源:repo_test.go
示例11: TestAddLocalCharm
func (s *clientSuite) TestAddLocalCharm(c *gc.C) {
charmArchive := charmtesting.Charms.Bundle(c.MkDir(), "dummy")
curl := charm.MustParseURL(
fmt.Sprintf("local:quantal/%s-%d", charmArchive.Meta().Name, charmArchive.Revision()),
)
client := s.APIState.Client()
// Test the sanity checks first.
_, err := client.AddLocalCharm(charm.MustParseURL("cs:quantal/wordpress-1"), nil)
c.Assert(err, gc.ErrorMatches, `expected charm URL with local: schema, got "cs:quantal/wordpress-1"`)
// Upload an archive with its original revision.
savedURL, err := client.AddLocalCharm(curl, charmArchive)
c.Assert(err, gc.IsNil)
c.Assert(savedURL.String(), gc.Equals, curl.String())
// Upload a charm directory with changed revision.
charmDir := charmtesting.Charms.ClonedDir(c.MkDir(), "dummy")
charmDir.SetDiskRevision(42)
savedURL, err = client.AddLocalCharm(curl, charmDir)
c.Assert(err, gc.IsNil)
c.Assert(savedURL.Revision, gc.Equals, 42)
// Upload a charm directory again, revision should be bumped.
savedURL, err = client.AddLocalCharm(curl, charmDir)
c.Assert(err, gc.IsNil)
c.Assert(savedURL.String(), gc.Equals, curl.WithRevision(43).String())
// Finally, try the NotImplementedError by mocking the server
// address to a handler that returns 405 Method Not Allowed for
// POST.
lis, err := net.Listen("tcp", "127.0.0.1:0")
c.Assert(err, gc.IsNil)
defer lis.Close()
url := fmt.Sprintf("http://%v", lis.Addr())
http.HandleFunc("/charms", func(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}
})
go func() {
http.Serve(lis, nil)
}()
api.SetServerRoot(client, url)
_, err = client.AddLocalCharm(curl, charmArchive)
c.Assert(err, jc.Satisfies, params.IsCodeNotImplemented)
}
开发者ID:klyachin,项目名称:juju,代码行数:48,代码来源:client_test.go
示例12: TestCharmPublishError
func (s *StoreSuite) TestCharmPublishError(c *gc.C) {
url := charm.MustParseURL("cs:oneiric/wordpress")
urls := []*charm.URL{url}
// Publish one successfully to bump the revision so we can
// make sure it is being correctly set below.
pub, err := s.store.CharmPublisher(urls, "one-digest")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 0)
err = pub.Publish(&FakeCharmDir{})
c.Assert(err, gc.IsNil)
pub, err = s.store.CharmPublisher(urls, "another-digest")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 1)
err = pub.Publish(&FakeCharmDir{error: "beforeWrite"})
c.Assert(err, gc.ErrorMatches, "beforeWrite")
pub, err = s.store.CharmPublisher(urls, "another-digest")
c.Assert(err, gc.IsNil)
c.Assert(pub.Revision(), gc.Equals, 1)
err = pub.Publish(&FakeCharmDir{error: "afterWrite"})
c.Assert(err, gc.ErrorMatches, "afterWrite")
// Still at the original charm revision that succeeded first.
info, err := s.store.CharmInfo(url)
c.Assert(err, gc.IsNil)
c.Assert(info.Revision(), gc.Equals, 0)
c.Assert(info.Digest(), gc.Equals, "one-digest")
}
开发者ID:rogpeppe,项目名称:charmstore,代码行数:30,代码来源:store_test.go
示例13: TestInfoError
func (s *StoreSuite) TestInfoError(c *gc.C) {
charmURL := charm.MustParseURL("cs:series/borken")
info, err := s.store.Info(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(info, gc.HasLen, 1)
c.Assert(info[0].Errors, gc.DeepEquals, []string{"badness"})
}
开发者ID:bz2,项目名称:charm,代码行数:7,代码来源:repo_test.go
示例14: TestCharmErrorEvents
func (s *FilterSuite) TestCharmErrorEvents(c *gc.C) {
f, err := newFilter(s.uniter, s.unit.Tag().String())
c.Assert(err, gc.IsNil)
defer f.Stop() // no AssertStop, we test for an error below
assertNoChange := func() {
s.BackingState.StartSync()
select {
case <-f.ConfigEvents():
c.Fatalf("unexpected config event")
case <-time.After(coretesting.ShortWait):
}
}
// Check setting an invalid charm URL does not send events.
err = f.SetCharm(charm.MustParseURL("cs:missing/one-1"))
c.Assert(err, gc.Equals, tomb.ErrDying)
assertNoChange()
s.assertFilterDies(c, f)
// Filter died after the error, so restart it.
f, err = newFilter(s.uniter, s.unit.Tag().String())
c.Assert(err, gc.IsNil)
defer f.Stop() // no AssertStop, we test for an error below
// Check with a nil charm URL, again no changes.
err = f.SetCharm(nil)
c.Assert(err, gc.Equals, tomb.ErrDying)
assertNoChange()
s.assertFilterDies(c, f)
}
开发者ID:klyachin,项目名称:juju,代码行数:31,代码来源:filter_test.go
示例15: TestCharmDir
func (s *DeploySuite) TestCharmDir(c *gc.C) {
charmtesting.Charms.ClonedDirPath(s.SeriesPath, "dummy")
err := runDeploy(c, "local:dummy")
c.Assert(err, gc.IsNil)
curl := charm.MustParseURL("local:precise/dummy-1")
s.AssertService(c, "dummy", curl, 1, 0)
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:deploy_test.go
示例16: TestNumUnits
func (s *DeploySuite) TestNumUnits(c *gc.C) {
charmtesting.Charms.BundlePath(s.SeriesPath, "dummy")
err := runDeploy(c, "local:dummy", "-n", "13")
c.Assert(err, gc.IsNil)
curl := charm.MustParseURL("local:precise/dummy-1")
s.AssertService(c, "dummy", curl, 13, 0)
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:deploy_test.go
示例17: TestSubordinateCharm
func (s *DeploySuite) TestSubordinateCharm(c *gc.C) {
charmtesting.Charms.BundlePath(s.SeriesPath, "logging")
err := runDeploy(c, "local:logging")
c.Assert(err, gc.IsNil)
curl := charm.MustParseURL("local:precise/logging-1")
s.AssertService(c, "logging", curl, 0, 0)
}
开发者ID:klyachin,项目名称:juju,代码行数:7,代码来源:deploy_test.go
示例18: TestInfoWarning
func (s *StoreSuite) TestInfoWarning(c *gc.C) {
charmURL := charm.MustParseURL("cs:series/unwise")
info, err := s.store.Info(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(info, gc.HasLen, 1)
c.Assert(info[0].Warnings, gc.DeepEquals, []string{"foolishness"})
}
开发者ID:bz2,项目名称:charm,代码行数:7,代码来源:repo_test.go
示例19: SetUpTest
func (s *DeployLocalSuite) SetUpTest(c *gc.C) {
s.JujuConnSuite.SetUpTest(c)
curl := charm.MustParseURL("local:quantal/dummy")
charm, err := testing.PutCharm(s.State, curl, s.repo, false)
c.Assert(err, gc.IsNil)
s.charm = charm
}
开发者ID:jiasir,项目名称:juju,代码行数:7,代码来源:deploy_test.go
示例20: TestMultipleVersions
func (s *LocalRepoSuite) TestMultipleVersions(c *gc.C) {
charmURL := charm.MustParseURL("local:quantal/upgrade")
s.addDir("upgrade1")
rev, err := charm.Latest(s.repo, charmURL)
c.Assert(err, gc.IsNil)
c.Assert(rev, gc.Equals, 1)
ch, err := s.repo.Get(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(ch.Revision(), gc.Equals, 1)
s.addDir("upgrade2")
rev, err = charm.Latest(s.repo, charmURL)
c.Assert(err, gc.IsNil)
c.Assert(rev, gc.Equals, 2)
ch, err = s.repo.Get(charmURL)
c.Assert(err, gc.IsNil)
c.Assert(ch.Revision(), gc.Equals, 2)
revCharmURL := charmURL.WithRevision(1)
rev, err = charm.Latest(s.repo, revCharmURL)
c.Assert(err, gc.IsNil)
c.Assert(rev, gc.Equals, 2)
ch, err = s.repo.Get(revCharmURL)
c.Assert(err, gc.IsNil)
c.Assert(ch.Revision(), gc.Equals, 1)
badRevCharmURL := charmURL.WithRevision(33)
rev, err = charm.Latest(s.repo, badRevCharmURL)
c.Assert(err, gc.IsNil)
c.Assert(rev, gc.Equals, 2)
_, err = s.repo.Get(badRevCharmURL)
s.checkNotFoundErr(c, err, badRevCharmURL)
}
开发者ID:bz2,项目名称:charm,代码行数:33,代码来源:repo_test.go
注:本文中的github.com/juju/charm.MustParseURL函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论