本文整理汇总了Golang中github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/uuid/fakes.FakeGenerator.GeneratedUUID方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeGenerator.GeneratedUUID方法的具体用法?Golang FakeGenerator.GeneratedUUID怎么用?Golang FakeGenerator.GeneratedUUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/uuid/fakes.FakeGenerator
的用法示例。
在下文中一共展示了FakeGenerator.GeneratedUUID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
ConfigurationHash: "",
}
//TODO: use a real state builder
mockStateBuilderFactory.EXPECT().NewBuilder(mockBlobstore, mockAgentClient).Return(mockStateBuilder).AnyTimes()
mockStateBuilder.EXPECT().Build(jobName, jobIndex, gomock.Any(), gomock.Any()).Return(mockState, nil).AnyTimes()
mockState.EXPECT().ToApplySpec().Return(applySpec).AnyTimes()
}
var newDeployCmd = func() Cmd {
deploymentParser := bideplmanifest.NewParser(fs, logger)
releaseSetValidator := birelsetmanifest.NewValidator(logger)
releaseSetParser := birelsetmanifest.NewParser(fs, logger, releaseSetValidator)
fakeRegistryUUIDGenerator = fakeuuid.NewFakeGenerator()
fakeRegistryUUIDGenerator.GeneratedUUID = "registry-password"
installationValidator := biinstallmanifest.NewValidator(logger)
installationParser := biinstallmanifest.NewParser(fs, fakeRegistryUUIDGenerator, logger, installationValidator)
deploymentValidator := bideplmanifest.NewValidator(logger)
instanceFactory := biinstance.NewFactory(mockStateBuilderFactory)
instanceManagerFactory := biinstance.NewManagerFactory(sshTunnelFactory, instanceFactory, logger)
pingTimeout := 1 * time.Second
pingDelay := 100 * time.Millisecond
deploymentFactory := bidepl.NewFactory(pingTimeout, pingDelay)
ui := biui.NewWriterUI(stdOut, stdErr, logger)
doGet := func(deploymentManifestPath string) (DeploymentPreparer, error) {
// todo: figure this out?
示例2: rootDesc
//.........这里部分代码省略.........
mockInstallerFactory = mock_install.NewMockInstallerFactory(mockCtrl)
mockReleaseExtractor = mock_release.NewMockExtractor(mockCtrl)
releaseManager = birel.NewManager(logger)
mockRegistryServerManager = mock_registry.NewMockServerManager(mockCtrl)
mockRegistryServer = mock_registry.NewMockServer(mockCtrl)
mockAgentClientFactory = mock_httpagent.NewMockAgentClientFactory(mockCtrl)
mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl)
mockAgentClientFactory.EXPECT().NewAgentClient(gomock.Any(), gomock.Any()).Return(mockAgentClient).AnyTimes()
mockCloudFactory = mock_cloud.NewMockFactory(mockCtrl)
mockBlobstoreFactory = mock_blobstore.NewMockFactory(mockCtrl)
mockBlobstore = mock_blobstore.NewMockBlobstore(mockCtrl)
mockBlobstoreFactory.EXPECT().Create(mbusURL).Return(mockBlobstore, nil).AnyTimes()
mockVMManagerFactory = mock_vm.NewMockManagerFactory(mockCtrl)
fakeVMManager = fakebivm.NewFakeManager()
mockVMManagerFactory.EXPECT().NewManager(gomock.Any(), mockAgentClient).Return(fakeVMManager).AnyTimes()
fakeStemcellExtractor = fakebistemcell.NewFakeExtractor()
mockStemcellManager = mock_stemcell.NewMockManager(mockCtrl)
fakeStemcellManagerFactory = fakebistemcell.NewFakeManagerFactory()
fakeReleaseSetParser = fakebirelsetmanifest.NewFakeParser()
fakeInstallationParser = fakebiinstallmanifest.NewFakeParser()
fakeDeploymentParser = fakebideplmanifest.NewFakeParser()
mockLegacyDeploymentStateMigrator = mock_config.NewMockLegacyDeploymentStateMigrator(mockCtrl)
configUUIDGenerator = &fakeuuid.FakeGenerator{}
configUUIDGenerator.GeneratedUUID = directorID
setupDeploymentStateService = biconfig.NewFileSystemDeploymentStateService(fakeFs, configUUIDGenerator, logger, biconfig.DeploymentStatePath(deploymentManifestPath))
fakeDeploymentValidator = fakebideplval.NewFakeValidator()
fakeStage = fakebiui.NewFakeStage()
sha1Calculator = crypto.NewSha1Calculator(fakeFs)
fakeUUIDGenerator = &fakeuuid.FakeGenerator{}
var err error
manifestSHA1, err = sha1Calculator.Calculate(deploymentManifestPath)
Expect(err).ToNot(HaveOccurred())
cpiReleaseTarballPath = "/release/tarball/path"
stemcellTarballPath = "/stemcell/tarball/path"
extractedStemcell = bistemcell.NewExtractedStemcell(
bistemcell.Manifest{
ImagePath: "/stemcell/image/path",
Name: "fake-stemcell-name",
Version: "fake-stemcell-version",
SHA1: "fake-stemcell-sha1",
CloudProperties: biproperty.Map{},
OS: "ubuntu-trusty",
},
"fake-extracted-path",
fakeFs,
)
// create input files
fakeFs.WriteFileString(cpiReleaseTarballPath, "")
fakeFs.WriteFileString(stemcellTarballPath, "")
示例3:
fakeCloud *fakebicloud.FakeCloud
fakeFs *fakesys.FakeFileSystem
fakeUUIDGenerator *fakeuuid.FakeGenerator
diskRepo biconfig.DiskRepo
)
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LevelNone)
fakeFs = fakesys.NewFakeFileSystem()
fakeUUIDGenerator = &fakeuuid.FakeGenerator{}
deploymentStateService := biconfig.NewFileSystemDeploymentStateService(fakeFs, fakeUUIDGenerator, logger, "/fake/path")
diskRepo = biconfig.NewDiskRepo(deploymentStateService, fakeUUIDGenerator)
managerFactory := NewManagerFactory(diskRepo, logger)
fakeCloud = fakebicloud.NewFakeCloud()
manager = managerFactory.NewManager(fakeCloud)
fakeUUIDGenerator.GeneratedUUID = "fake-uuid"
})
Describe("Create", func() {
var (
diskPool bideplmanifest.DiskPool
)
BeforeEach(func() {
diskPool = bideplmanifest.DiskPool{
Name: "fake-disk-pool-name",
DiskSize: 1024,
CloudProperties: biproperty.Map{
"fake-cloud-property-key": "fake-cloud-property-value",
},
示例4:
BeforeEach(func() {
fakeFs.WriteFileString(comboManifestPath, `
---
name: fake-deployment-name
cloud_provider:
template:
name: fake-cpi-job-name
release: fake-cpi-release-name
ssh_tunnel:
host: 54.34.56.8
port: 22
user: fake-ssh-user
private_key: /tmp/fake-ssh-key.pem
mbus: http://fake-mbus-user:[email protected]:6868
`)
fakeUUIDGenerator.GeneratedUUID = "fake-uuid"
})
It("generates registry config and populates properties in manifest with absolute path for private_key", func() {
installationManifest, err := parser.Parse(comboManifestPath, releaseSetManifest)
Expect(err).ToNot(HaveOccurred())
Expect(installationManifest).To(Equal(manifest.Manifest{
Name: "fake-deployment-name",
Template: manifest.ReleaseJobRef{
Name: "fake-cpi-job-name",
Release: "fake-cpi-release-name",
},
Properties: biproperty.Map{
"registry": biproperty.Map{
"host": "127.0.0.1",
示例5:
Expect(err).ToNot(HaveOccurred())
fileName := file.Name()
defer fs.RemoveAll(fileName)
err = blobstore.CleanUp(fileName)
Expect(err).ToNot(HaveOccurred())
Expect(fs.FileExists(fileName)).To(BeFalse())
})
})
Describe("Create", func() {
It("creates the local blob", func() {
fs.WriteFileString("/fake-file.txt", "fake-file-contents")
uuidGen.GeneratedUUID = "some-uuid"
blobID, fingerprint, err := blobstore.Create("/fake-file.txt")
Expect(err).ToNot(HaveOccurred())
Expect(blobID).To(Equal("some-uuid"))
Expect(fingerprint).To(BeEmpty())
dirStats := fs.GetFileTestStat(fakeBlobstorePath)
Expect(dirStats).ToNot(BeNil())
Expect(dirStats.FileMode).To(Equal(os.FileMode(0770)))
writtenFileStats := fs.GetFileTestStat(fakeBlobstorePath + "/some-uuid")
Expect(writtenFileStats).ToNot(BeNil())
Expect("fake-file-contents").To(Equal(writtenFileStats.StringContents()))
})
示例6:
reader *fakebistemcell.FakeStemcellReader
fakeCloud *fakebicloud.FakeCloud
fakeStage *fakebiui.FakeStage
stemcellTarballPath string
tempExtractionDir string
expectedExtractedStemcell ExtractedStemcell
)
BeforeEach(func() {
fs = fakesys.NewFakeFileSystem()
reader = fakebistemcell.NewFakeReader()
logger := boshlog.NewLogger(boshlog.LevelNone)
fakeUUIDGenerator = &fakeuuid.FakeGenerator{}
deploymentStateService := biconfig.NewFileSystemDeploymentStateService(fs, fakeUUIDGenerator, logger, "/fake/path")
fakeUUIDGenerator.GeneratedUUID = "fake-stemcell-id-1"
stemcellRepo = biconfig.NewStemcellRepo(deploymentStateService, fakeUUIDGenerator)
fakeStage = fakebiui.NewFakeStage()
fakeCloud = fakebicloud.NewFakeCloud()
manager = NewManager(stemcellRepo, fakeCloud)
stemcellTarballPath = "/stemcell/tarball/path"
tempExtractionDir = "/path/to/dest"
fs.TempDirDir = tempExtractionDir
expectedExtractedStemcell = NewExtractedStemcell(
Manifest{
Name: "fake-stemcell-name",
Version: "fake-stemcell-version",
ImagePath: "fake-image-path",
CloudProperties: biproperty.Map{
"fake-prop-key": "fake-prop-value",
示例7: rootDesc
func rootDesc() {
var (
repo ReleaseRepo
deploymentStateService DeploymentStateService
fs *fakesys.FakeFileSystem
fakeUUIDGenerator *fakeuuid.FakeGenerator
)
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LevelNone)
fs = fakesys.NewFakeFileSystem()
fakeUUIDGenerator = &fakeuuid.FakeGenerator{}
fakeUUIDGenerator.GeneratedUUID = "fake-uuid"
deploymentStateService = NewFileSystemDeploymentStateService(fs, fakeUUIDGenerator, logger, "/fake/path")
deploymentStateService.Load()
repo = NewReleaseRepo(deploymentStateService, fakeUUIDGenerator)
})
Describe("List", func() {
Context("when a current release exists", func() {
BeforeEach(func() {
conf, err := deploymentStateService.Load()
Expect(err).ToNot(HaveOccurred())
conf.Releases = []ReleaseRecord{
ReleaseRecord{ID: "fake-guid-a", Name: "fake-name-a", Version: "fake-version-a"},
ReleaseRecord{ID: "fake-guid-b", Name: "fake-name-b", Version: "fake-version-b"},
}
err = deploymentStateService.Save(conf)
Expect(err).ToNot(HaveOccurred())
})
It("returns existing release", func() {
records, err := repo.List()
Expect(err).ToNot(HaveOccurred())
Expect(records).To(Equal([]ReleaseRecord{
{
ID: "fake-guid-a",
Name: "fake-name-a",
Version: "fake-version-a",
},
{
ID: "fake-guid-b",
Name: "fake-name-b",
Version: "fake-version-b",
},
}))
})
})
Context("when there are no releases recorded", func() {
It("returns not found", func() {
records, err := repo.List()
Expect(err).ToNot(HaveOccurred())
Expect(records).To(HaveLen(0))
})
})
Context("when the config service fails to load", func() {
BeforeEach(func() {
fs.ReadFileError = errors.New("kaboom")
})
It("returns an error", func() {
_, err := repo.List()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("Loading existing config"))
})
})
})
Describe("Update", func() {
Context("when there are no existing releases", func() {
It("saves the provided releases to the config file", func() {
err := repo.Update([]release.Release{
fakerelease.New("name1", "1"),
fakerelease.New("name2", "2"),
})
Expect(err).ToNot(HaveOccurred())
conf, err := deploymentStateService.Load()
Expect(err).ToNot(HaveOccurred())
Expect(conf.Releases).To(ConsistOf(
ReleaseRecord{ID: "fake-uuid", Name: "name1", Version: "1"},
ReleaseRecord{ID: "fake-uuid", Name: "name2", Version: "2"},
))
})
})
Context("when the existing releases exactly match the provided releases", func() {
BeforeEach(func() {
conf, err := deploymentStateService.Load()
Expect(err).ToNot(HaveOccurred())
conf.Releases = []ReleaseRecord{
ReleaseRecord{ID: "old-uuid", Name: "name1", Version: "1"},
ReleaseRecord{ID: "old-uuid", Name: "name2", Version: "2"},
}
err = deploymentStateService.Save(conf)
Expect(err).ToNot(HaveOccurred())
})
})
//.........这里部分代码省略.........
示例8:
Context("when getting from blobstore fails", func() {
It("returns an error", func() {
fakeDavClient.GetErr = errors.New("fake-get-error")
_, err := blobstore.Get("fake-blob-id")
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("fake-get-error"))
})
})
})
Describe("Add", func() {
BeforeEach(func() {
fs.RegisterOpenFile("fake-source-path", &fakesys.FakeFile{
Contents: []byte("fake-contents"),
})
})
It("adds file to blobstore and returns its blob ID", func() {
fakeUUIDGenerator.GeneratedUUID = "fake-blob-id"
blobID, err := blobstore.Add("fake-source-path")
Expect(err).ToNot(HaveOccurred())
Expect(blobID).To(Equal("fake-blob-id"))
Expect(fakeDavClient.PutPath).To(Equal("fake-blob-id"))
Expect(fakeDavClient.PutContents).To(Equal("fake-contents"))
})
})
})