本文整理汇总了Golang中github.com/juju/juju/environs/tools.NewGeneralToolsConstraint函数的典型用法代码示例。如果您正苦于以下问题:Golang NewGeneralToolsConstraint函数的具体用法?Golang NewGeneralToolsConstraint怎么用?Golang NewGeneralToolsConstraint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewGeneralToolsConstraint函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestFetchWithMirror
func (s *simplestreamsSuite) TestFetchWithMirror(c *gc.C) {
toolsConstraint := tools.NewGeneralToolsConstraint(1, 13, simplestreams.LookupParams{
CloudSpec: simplestreams.CloudSpec{"us-west-2", "https://ec2.us-west-2.amazonaws.com"},
Series: []string{"precise"},
Arches: []string{"amd64"},
Stream: "released",
})
toolsMetadata, resolveInfo, err := tools.Fetch(
[]simplestreams.DataSource{s.Source}, toolsConstraint)
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(toolsMetadata), gc.Equals, 1)
expectedMetadata := &tools.ToolsMetadata{
Release: "precise",
Version: "1.13.0",
Arch: "amd64",
Size: 2973595,
Path: "mirrored-path/juju-1.13.0-precise-amd64.tgz",
FullPath: "test:/mirrored-path/juju-1.13.0-precise-amd64.tgz",
FileType: "tar.gz",
SHA256: "447aeb6a934a5eaec4f703eda4ef2dde",
}
c.Assert(err, jc.ErrorIsNil)
c.Assert(toolsMetadata[0], gc.DeepEquals, expectedMetadata)
c.Assert(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{
Source: "test",
Signed: s.RequireSigned,
IndexURL: "test:/streams/v1/index.json",
MirrorURL: "test:/",
})
}
示例2: TestIdWithMajorMinorVersion
func (s *productSpecSuite) TestIdWithMajorMinorVersion(c *gc.C) {
toolsConstraint := tools.NewGeneralToolsConstraint(1, 2, false, simplestreams.LookupParams{
Series: []string{"precise"},
Arches: []string{"amd64"},
})
ids, err := toolsConstraint.Ids()
c.Assert(err, gc.IsNil)
c.Assert(ids, gc.DeepEquals, []string{`com.ubuntu.juju:12.04:amd64`})
}
示例3: TestIdWithMajorVersionOnly
func (s *productSpecSuite) TestIdWithMajorVersionOnly(c *gc.C) {
toolsConstraint := tools.NewGeneralToolsConstraint(1, -1, simplestreams.LookupParams{
Series: []string{"precise"},
Arches: []string{"amd64"},
Stream: "released",
})
ids, err := toolsConstraint.ProductIds()
c.Assert(err, jc.ErrorIsNil)
c.Assert(ids, gc.DeepEquals, []string{`com.ubuntu.juju:12.04:amd64`})
}
示例4: TestFetchNoMatchingStream
func (s *simplestreamsSuite) TestFetchNoMatchingStream(c *gc.C) {
toolsConstraint := tools.NewGeneralToolsConstraint(2, -1, simplestreams.LookupParams{
CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"},
Series: []string{"precise"},
Arches: []string{},
Stream: "proposed",
})
_, _, err := tools.Fetch(
[]simplestreams.DataSource{s.Source}, toolsConstraint)
c.Assert(err, gc.ErrorMatches, `"content-download" data not found`)
}
示例5: TestFetch
func (s *simplestreamsSuite) TestFetch(c *gc.C) {
for i, t := range fetchTests {
c.Logf("test %d", i)
if t.stream == "" {
t.stream = "released"
}
var toolsConstraint *tools.ToolsConstraint
if t.version == "" {
toolsConstraint = tools.NewGeneralToolsConstraint(t.major, t.minor, simplestreams.LookupParams{
CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"},
Series: []string{t.series},
Arches: t.arches,
Stream: t.stream,
})
} else {
toolsConstraint = tools.NewVersionedToolsConstraint(version.MustParse(t.version),
simplestreams.LookupParams{
CloudSpec: simplestreams.CloudSpec{"us-east-1", "https://ec2.us-east-1.amazonaws.com"},
Series: []string{t.series},
Arches: t.arches,
Stream: t.stream,
})
}
// Add invalid datasource and check later that resolveInfo is correct.
invalidSource := simplestreams.NewURLDataSource("invalid", "file://invalid", utils.VerifySSLHostnames, simplestreams.DEFAULT_CLOUD_DATA, s.RequireSigned)
tools, resolveInfo, err := tools.Fetch(
[]simplestreams.DataSource{invalidSource, s.Source}, toolsConstraint)
if !c.Check(err, jc.ErrorIsNil) {
continue
}
for _, tm := range t.tools {
tm.FullPath, err = s.Source.URL(tm.Path)
c.Assert(err, jc.ErrorIsNil)
}
c.Check(tools, gc.DeepEquals, t.tools)
c.Check(resolveInfo, gc.DeepEquals, &simplestreams.ResolveInfo{
Source: "test",
Signed: s.RequireSigned,
IndexURL: "test:/streams/v1/index.json",
MirrorURL: "",
})
}
}