當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeCake.GetStub方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/garden-shed/layercake/fake_cake.FakeCake.GetStub方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeCake.GetStub方法的具體用法?Golang FakeCake.GetStub怎麽用?Golang FakeCake.GetStub使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/garden-shed/layercake/fake_cake.FakeCake的用法示例。


在下文中一共展示了FakeCake.GetStub方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

	)

	BeforeEach(func() {
		fakeThreshold = new(fakes.FakeThreshold)
		logger = lagertest.NewTestLogger("test")

		retainer = cleaner.NewRetainer()

		fakeCake = new(fake_cake.FakeCake)
		fakeCake.GetStub = func(id layercake.ID) (*image.Image, error) {
			if parent, ok := child2parent[id]; ok {
				return &image.Image{
					ID:     id.GraphID(),
					Parent: parent.GraphID(),
					Size:   size[id],
				}, nil
			}

			return &image.Image{
				Size: size[id],
			}, nil
		}

		fakeCake.IsLeafStub = func(id layercake.ID) (bool, error) {
			for _, p := range child2parent {
				if p == id {
					return false, nil
				}
			}

			return true, nil
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:31,代碼來源:cleaner_test.go

示例2:

					fakeCake.GetReturns(&image.Image{
						Size: 1234,
					}, nil)

					size, err := baseSizer.BaseSize(logger, "/i/do/exist")
					Expect(err).NotTo(HaveOccurred())
					Expect(size).To(BeNumerically("==", 1234))
				})
			})

			Context("and has parents", func() {
				It("returns the total size of all the parents", func() {
					imgs := map[string]*image.Image{
						"child":   &image.Image{Parent: "parent1", Size: 1234},
						"parent1": &image.Image{Parent: "parent2", Size: 456},
						"parent2": &image.Image{Size: 789},
					}

					fakeCake.GetStub = func(id layercake.ID) (*image.Image, error) {
						return imgs[id.GraphID()], nil
					}

					size, err := baseSizer.BaseSize(logger, "/i/have/parent/layers/child")
					Expect(err).NotTo(HaveOccurred())
					Expect(size).To(BeNumerically("==", 1234+456+789))
				})
			})
		})
	})
})
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:30,代碼來源:aufs_base_sizer_test.go

示例3:

					isLeaf, err := aufsCake.IsLeaf(parentID)
					Expect(err).NotTo(HaveOccurred())
					Expect(isLeaf).To(BeFalse())
				})

				It("keeps child-parent relationship information", func() {
					cake.GetStub = func(id layercake.ID) (*image.Image, error) {
						if id != parentID &&
							id != childID &&
							id != namespacedChildID &&
							id != otherNamespacedChildID {
							return nil, testError
						}

						img := &image.Image{
							ID: id.GraphID(),
						}

						if id == childID {
							img.Parent = parentID.GraphID()
						}

						return img, nil
					}

					Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Succeed())
					img, err := aufsCake.Get(namespacedChildID)
					Expect(err).NotTo(HaveOccurred())
					Expect(img.Parent).To(Equal(parentID.GraphID()))
				})
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:30,代碼來源:aufs_test.go

示例4:

					})
				})
			})

			Context("and the image has already been translated", func() {
				BeforeEach(func() {
					fakeCake.PathStub = func(id layercake.ID) (string, error) {
						return "/mount/point/" + id.GraphID(), nil
					}

					fakeNamespacer.CacheKeyReturns("sandwich")

					fakeCake.GetStub = func(id layercake.ID) (*image.Image, error) {
						if id == (layercake.NamespacedID(layercake.DockerImageID("some-image-id"), "sandwich")) {
							return &image.Image{}, nil
						}

						return nil, errors.New("hello")
					}

				})

				It("reuses the translated layer", func() {
					mountpoint, envvars, err := provider.Create(
						lagertest.NewTestLogger("test"),
						"some-id",
						&repository_fetcher.Image{
							ImageID: "some-image-id",
							Env:     []string{"env1=env1value", "env2=env2value"},
						},
						rootfs_provider.Spec{
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:31,代碼來源:layer_creator_test.go

示例5:

		}

		fakeConn.GetBlobReaderStub = func(_ lager.Logger, digest digest.Digest) (io.Reader, error) {
			return bytes.NewReader([]byte(blobs[digest])), nil
		}

		fakeDialer = new(fakes.FakeDialer)
		fakeDialer.DialStub = func(_ lager.Logger, host, repo string) (distclient.Conn, error) {
			return fakeConn, nil
		}

		fakeCake = new(fake_cake.FakeCake)
		fakeCake.GetStub = func(id layercake.ID) (*image.Image, error) {
			if _, ok := existingLayers[id.GraphID()]; ok {
				return &image.Image{Size: 33}, nil
			}

			return nil, errors.New("doesnt exist")
		}

		fakeVerifier = new(fakes.FakeVerifier)
		fakeVerifier.VerifyStub = func(r io.Reader, d digest.Digest) (io.ReadCloser, error) {
			return &verified{Reader: r}, nil
		}

		remote = repository_fetcher.NewRemote(lagertest.NewTestLogger("test"), defaultDockerRegistryHost, fakeCake, fakeDialer, fakeVerifier)
	})

	Context("when the URL has a host", func() {
		It("dials that host", func() {
			_, err := remote.Fetch(parseURL("docker://some-host/some/repo#some-tag"), 1234)
開發者ID:cloudfoundry,項目名稱:garden-shed,代碼行數:31,代碼來源:remote_test.go


注:本文中的code/cloudfoundry/org/garden-shed/layercake/fake_cake.FakeCake.GetStub方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。