本文整理汇总了Golang中github.com/juju/juju/environs/tools/testing.GetMockBundleTools函数的典型用法代码示例。如果您正苦于以下问题:Golang GetMockBundleTools函数的具体用法?Golang GetMockBundleTools怎么用?Golang GetMockBundleTools使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetMockBundleTools函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *BootstrapSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.MgoSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
// Set version.Current to a known value, for which we
// will make tools available. Individual tests may
// override this.
s.PatchValue(&version.Current, v100p64.Number)
s.PatchValue(&arch.HostArch, func() string { return v100p64.Arch })
s.PatchValue(&series.HostSeries, func() string { return v100p64.Series })
s.PatchValue(&jujuos.HostOS, func() jujuos.OSType { return jujuos.Ubuntu })
// Set up a local source with tools.
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
s.mockBlockClient = &mockBlockClient{}
s.PatchValue(&blockAPI, func(c *modelcmd.ModelCommandBase) (block.BlockListAPI, error) {
return s.mockBlockClient, nil
})
s.modelFlags = []string{"-m", "--model"}
}
开发者ID:pmatulis,项目名称:juju,代码行数:26,代码来源:bootstrap_test.go
示例2: TestSyncTools
func (s *uploadSuite) TestSyncTools(c *gc.C) {
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
builtTools, err := sync.BuildToolsTarball(nil)
c.Assert(err, gc.IsNil)
t, err := sync.SyncBuiltTools(s.env.Storage(), builtTools)
c.Assert(err, gc.IsNil)
c.Assert(t.Version, gc.Equals, version.Current)
c.Assert(t.URL, gc.Not(gc.Equals), "")
}
开发者ID:zhouqt,项目名称:juju,代码行数:9,代码来源:sync_test.go
示例3: SetUpTest
func (t *LiveTests) SetUpTest(c *gc.C) {
t.CleanupSuite.SetUpTest(c)
storageDir := c.MkDir()
t.DefaultBaseURL = "file://" + storageDir + "/tools"
t.ToolsFixture.SetUpTest(c)
stor, err := filestorage.NewFileStorageWriter(storageDir)
c.Assert(err, jc.ErrorIsNil)
t.UploadFakeTools(c, stor, "released", "released")
t.toolsStorage = stor
t.CleanupSuite.PatchValue(&envtools.BundleTools, envtoolstesting.GetMockBundleTools(c))
}
开发者ID:Pankov404,项目名称:juju,代码行数:11,代码来源:livetests.go
示例4: SetUpTest
func (s *BootstrapSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.MgoSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
// Set up a local source with tools.
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
}
开发者ID:zhouqt,项目名称:juju,代码行数:11,代码来源:bootstrap_test.go
示例5: TestBootstrapTools
func (s *bootstrapSuite) TestBootstrapTools(c *gc.C) {
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
allTests := append(envtesting.BootstrapToolsTests, bootstrapSetAgentVersionTests...)
// version.Current is set in the loop so ensure it is restored later.
s.PatchValue(&version.Current, version.Current)
for i, test := range allTests {
c.Logf("\ntest %d: %s", i, test.Info)
dummy.Reset()
attrs := dummy.SampleConfig().Merge(coretesting.Attrs{
"state-server": false,
"development": test.Development,
"default-series": test.DefaultSeries,
})
if test.AgentVersion != version.Zero {
attrs["agent-version"] = test.AgentVersion.String()
}
cfg, err := config.New(config.NoDefaults, attrs)
c.Assert(err, gc.IsNil)
env, err := environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem())
c.Assert(err, gc.IsNil)
envtesting.RemoveAllTools(c, env)
version.Current = test.CliVersion
envtesting.AssertUploadFakeToolsVersions(c, env.Storage(), test.Available...)
// Remove the default tools URL from the search path, just look in cloud storage.
s.PatchValue(&envtools.DefaultBaseURL, "")
cons := constraints.Value{}
if test.Arch != "" {
cons = constraints.MustParse("arch=" + test.Arch)
}
err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{Constraints: cons})
if test.Err != "" {
c.Check(err, gc.NotNil)
if err != nil {
stripped := strings.Replace(err.Error(), "\n", "", -1)
c.Check(stripped, gc.Matches, ".*"+stripped)
}
continue
} else {
c.Check(err, gc.IsNil)
}
unique := map[version.Number]bool{}
for _, expected := range test.Expect {
unique[expected.Number] = true
}
for expectAgentVersion := range unique {
agentVersion, ok := env.Config().AgentVersion()
c.Check(ok, gc.Equals, true)
c.Check(agentVersion, gc.Equals, expectAgentVersion)
}
}
}
开发者ID:klyachin,项目名称:juju,代码行数:53,代码来源:bootstrap_test.go
示例6: TestBuildToolsBadBuild
func (s *badBuildSuite) TestBuildToolsBadBuild(c *gc.C) {
// Test that original BuildAgentTarball fails
builtTools, err := sync.BuildAgentTarball(true, nil, "released")
c.Assert(err, gc.ErrorMatches, `cannot build jujud agent binary from source: build command \"go\" failed: exit status 1; `)
c.Assert(builtTools, gc.IsNil)
// Test that BuildAgentTarball func passes after BundleTools func is
// mocked out
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c, nil))
builtTools, err = sync.BuildAgentTarball(true, nil, "released")
s.assertEqualsCurrentVersion(c, builtTools.Version)
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:sync_test.go
示例7: TestUploadToolsBadBuild
func (s *badBuildSuite) TestUploadToolsBadBuild(c *gc.C) {
// Test that original Upload Func fails as expected
t, err := sync.Upload(s.env.Storage(), nil)
c.Assert(t, gc.IsNil)
c.Assert(err, gc.ErrorMatches, `build command "go" failed: exit status 1; `)
// Test that Upload func passes after BundleTools func is mocked out
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
t, err = sync.Upload(s.env.Storage(), nil)
c.Assert(err, gc.IsNil)
c.Assert(t.Version, gc.Equals, version.Current)
c.Assert(t.URL, gc.Not(gc.Equals), "")
}
开发者ID:zhouqt,项目名称:juju,代码行数:13,代码来源:sync_test.go
示例8: TestBuildToolsBadBuild
func (s *badBuildSuite) TestBuildToolsBadBuild(c *gc.C) {
// Test that original BuildToolsTarball fails
builtTools, err := sync.BuildToolsTarball(nil)
c.Assert(err, gc.ErrorMatches, `build command "go" failed: exit status 1; `)
c.Assert(builtTools, gc.IsNil)
// Test that BuildToolsTarball func passes after BundleTools func is
// mocked out
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
builtTools, err = sync.BuildToolsTarball(nil)
c.Assert(builtTools.Version, gc.Equals, version.Current)
c.Assert(err, gc.IsNil)
}
开发者ID:zhouqt,项目名称:juju,代码行数:13,代码来源:sync_test.go
示例9: setupAutoUploadTest
func (s *BootstrapSuite) setupAutoUploadTest(c *gc.C, vers, series string) environs.Environ {
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
// Change the tools location to be the test location and also
// the version and ensure their later restoring.
// Set the current version to be something for which there are no tools
// so we can test that an upload is forced.
s.PatchValue(&version.Current, version.MustParseBinary(vers+"-"+series+"-"+arch.HostArch()))
// Create home with dummy provider and remove all
// of its envtools.
return resetJujuHome(c, "devenv")
}
开发者ID:kakamessi99,项目名称:juju,代码行数:15,代码来源:bootstrap_test.go
示例10: TestUploadToolsBadBuild
func (s *badBuildSuite) TestUploadToolsBadBuild(c *gc.C) {
stor, err := filestorage.NewFileStorageWriter(c.MkDir())
c.Assert(err, jc.ErrorIsNil)
// Test that original Upload Func fails as expected
t, err := sync.Upload(stor, "released", nil)
c.Assert(t, gc.IsNil)
c.Assert(err, gc.ErrorMatches, `cannot build jujud agent binary from source: build command \"go\" failed: exit status 1; `)
// Test that Upload func passes after BundleTools func is mocked out
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c, nil))
t, err = sync.Upload(stor, "released", nil)
c.Assert(err, jc.ErrorIsNil)
s.assertEqualsCurrentVersion(c, t.Version)
c.Assert(t.URL, gc.Not(gc.Equals), "")
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:sync_test.go
示例11: SetUpTest
func (s *uploadSuite) SetUpTest(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
s.FakeJujuHomeSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
// Create a target storage.
stor, err := filestorage.NewFileStorageWriter(c.MkDir())
c.Assert(err, jc.ErrorIsNil)
s.targetStorage = stor
// Mock out building of tools. Sync should not care about the contents
// of tools archives, other than that they hash correctly.
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
}
开发者ID:pmatulis,项目名称:juju,代码行数:16,代码来源:sync_test.go
示例12: TestBundleToolsBadBuild
func (s *badBuildSuite) TestBundleToolsBadBuild(c *gc.C) {
// Test that original bundleTools Func fails as expected
vers, sha256Hash, err := bundleTools(c)
c.Assert(vers, gc.DeepEquals, version.Binary{})
c.Assert(sha256Hash, gc.Equals, "")
c.Assert(err, gc.ErrorMatches, `build command "go" failed: exit status 1; `)
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
// Test that BundleTools func passes after it is
// mocked out
vers, sha256Hash, err = bundleTools(c)
c.Assert(err, gc.IsNil)
c.Assert(vers.Number, gc.Equals, version.Current.Number)
c.Assert(sha256Hash, gc.Equals, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
}
开发者ID:zhouqt,项目名称:juju,代码行数:16,代码来源:sync_test.go
示例13: setupAutoUploadTest
func (s *BootstrapSuite) setupAutoUploadTest(c *gc.C, vers, series string) environs.Environ {
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
// Change the tools location to be the test location and also
// the version and ensure their later restoring.
// Set the current version to be something for which there are no tools
// so we can test that an upload is forced.
origVersion := version.Current
version.Current.Number = version.MustParse(vers)
version.Current.Series = series
s.AddCleanup(func(*gc.C) { version.Current = origVersion })
// Create home with dummy provider and remove all
// of its envtools.
return resetJujuHome(c)
}
开发者ID:klyachin,项目名称:juju,代码行数:18,代码来源:bootstrap_test.go
示例14: assertUploadTools
func (s *bootstrapSuite) assertUploadTools(c *gc.C, vers version.Binary, forceVersion bool,
extraConfig map[string]interface{}, errMessage string) {
s.PatchValue(&version.Current, vers)
// If we allow released tools to be uploaded, the build number is incremented so in that case
// we need to ensure the environment is set up to allow dev tools to be used.
env := newEnviron("foo", useDefaultKeys, extraConfig)
s.setDummyStorage(c, env)
envtesting.RemoveFakeTools(c, env.Storage())
// At this point, as a result of setDummyStorage, env has tools for amd64 uploaded.
// Set version.Current to be arm64 to simulate a different CLI version.
cliVersion := version.Current
cliVersion.Arch = "arm64"
version.Current = cliVersion
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
// Host runs arm64, environment supports arm64.
s.PatchValue(&arch.HostArch, func() string {
return "arm64"
})
arch := "arm64"
err := bootstrap.UploadTools(coretesting.Context(c), env, &arch, forceVersion, "precise")
if errMessage != "" {
c.Assert(err, gc.NotNil)
stripped := strings.Replace(err.Error(), "\n", "", -1)
c.Assert(stripped, gc.Matches, errMessage)
return
}
c.Assert(err, gc.IsNil)
params := envtools.BootstrapToolsParams{
Arch: &arch,
Series: version.Current.Series,
}
agentTools, err := envtools.FindBootstrapTools(env, params)
c.Assert(err, gc.IsNil)
c.Assert(agentTools, gc.HasLen, 1)
expectedVers := vers
expectedVers.Number.Build++
expectedVers.Series = version.Current.Series
c.Assert(agentTools[0].Version, gc.DeepEquals, expectedVers)
}
开发者ID:klyachin,项目名称:juju,代码行数:41,代码来源:bootstrap_test.go
示例15: SetUpTest
func (s *BootstrapSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
s.MgoSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
// Set version.Current to a known value, for which we
// will make tools available. Individual tests may
// override this.
s.PatchValue(&version.Current, v100p64)
// Set up a local source with tools.
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
s.mockBlockClient = &mockBlockClient{}
s.PatchValue(&blockAPI, func(c *envcmd.EnvCommandBase) (block.BlockListAPI, error) {
return s.mockBlockClient, nil
})
}
开发者ID:mhilton,项目名称:juju,代码行数:21,代码来源:bootstrap_test.go
示例16: TestEnsureToolsAvailability
func (s *bootstrapSuite) TestEnsureToolsAvailability(c *gc.C) {
existingToolsVersion := version.MustParseBinary("1.19.0-trusty-amd64")
s.PatchValue(&version.Current, existingToolsVersion)
env := newEnviron("foo", useDefaultKeys, nil)
s.setDummyStorage(c, env)
// At this point, as a result of setDummyStorage, env has tools for amd64 uploaded.
// Set version.Current to be arm64 to simulate a different CLI version.
cliVersion := version.Current
cliVersion.Arch = "arm64"
version.Current = cliVersion
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
// Host runs arm64, environment supports arm64.
s.PatchValue(&arch.HostArch, func() string {
return "arm64"
})
arch := "arm64"
agentTools, err := bootstrap.EnsureToolsAvailability(coretesting.Context(c), env, config.PreferredSeries(env.Config()), &arch)
c.Assert(err, gc.IsNil)
c.Assert(agentTools, gc.HasLen, 1)
expectedVers := version.Current
expectedVers.Number.Build++
expectedVers.Series = config.PreferredSeries(env.Config())
c.Assert(agentTools[0].Version, gc.DeepEquals, expectedVers)
}
开发者ID:klyachin,项目名称:juju,代码行数:24,代码来源:bootstrap_test.go
示例17: SetUpTest
func (s *BootstrapSuite) SetUpTest(c *gc.C) {
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
s.MgoSuite.SetUpTest(c)
s.ToolsFixture.SetUpTest(c)
// Set jujuversion.Current to a known value, for which we
// will make tools available. Individual tests may
// override this.
s.PatchValue(&jujuversion.Current, v100p64.Number)
s.PatchValue(&arch.HostArch, func() string { return v100p64.Arch })
s.PatchValue(&series.HostSeries, func() string { return v100p64.Series })
s.PatchValue(&jujuos.HostOS, func() jujuos.OSType { return jujuos.Ubuntu })
// Set up a local source with tools.
sourceDir := createToolsSource(c, vAll)
s.PatchValue(&envtools.DefaultBaseURL, sourceDir)
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c))
s.mockBlockClient = &mockBlockClient{}
s.PatchValue(&blockAPI, func(c *modelcmd.ModelCommandBase) (block.BlockListAPI, error) {
err := s.mockBlockClient.loginError
if err != nil {
s.mockBlockClient.loginError = nil
return nil, err
}
if s.mockBlockClient.discoveringSpacesError > 0 {
s.mockBlockClient.discoveringSpacesError -= 1
return nil, errors.New("spaces are still being discovered")
}
return s.mockBlockClient, nil
})
// TODO(wallyworld) - add test data when tests are improved
s.store = jujuclienttesting.NewMemStore()
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:36,代码来源:bootstrap_test.go
示例18: patchBundleTools
func (s *uploadSuite) patchBundleTools(c *gc.C, v *version.Number) {
// Mock out building of tools. Sync should not care about the contents
// of tools archives, other than that they hash correctly.
s.PatchValue(&envtools.BundleTools, toolstesting.GetMockBundleTools(c, v))
}
开发者ID:bac,项目名称:juju,代码行数:5,代码来源:sync_test.go
注:本文中的github.com/juju/juju/environs/tools/testing.GetMockBundleTools函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论