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


Golang fakeclock.FakeClock類代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/clock/fakeclock.FakeClock的典型用法代碼示例。如果您正苦於以下問題:Golang FakeClock類的具體用法?Golang FakeClock怎麽用?Golang FakeClock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: init

func init() {
	sender = metrics_fakes.NewFakeMetricSender()
	metrics.Initialize(sender, nil)
}

var _ = Describe("RouteFetcher", func() {
	var (
		cfg         *config.Config
		uaaClient   *testUaaClient.FakeClient
		registry    *testRegistry.FakeRegistryInterface
		fetcher     *RouteFetcher
		logger      lager.Logger
		client      *fake_routing_api.FakeClient
		eventSource *fake_routing_api.FakeEventSource

		token *schema.Token

		response     []models.Route
		process      ifrit.Process
		eventChannel chan routing_api.Event
		errorChannel chan error

		clock *fakeclock.FakeClock
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		cfg = config.DefaultConfig()
		cfg.PruneStaleDropletsInterval = 2 * time.Millisecond

		retryInterval := 0
開發者ID:cloudfoundry,項目名稱:gorouter,代碼行數:31,代碼來源:route_fetcher_test.go

示例2:

	DefaultRetryInterval        = 15 * time.Second
	DefaultExpirationBufferTime = 30
	ValidPemPublicKey           = `-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHFr+KICms+tuT1OXJwhCUmR2d\nKVy7psa8xzElSyzqx7oJyfJ1JZyOzToj9T5SfTIq396agbHJWVfYphNahvZ/7uMX\nqHxf+ZH9BL1gk9Y6kCnbM5R60gfwjyW1/dQPjOzn9N394zd2FJoFHwdq9Qs0wBug\nspULZVNRxq7veq/fzwIDAQAB\n-----END PUBLIC KEY-----`
	InvalidPemPublicKey         = `-----BEGIN PUBLIC KEY-----\nMJGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHFr+KICms+tuT1OXJwhCUmR2d\nKVy7psa8xzElSyzqx7oJyfJ1JZyOzToj9T5SfTIq396agbHJWVfYphNahvZ/7uMX\nqHxf+ZH9BL1gk9Y6kCnbM5R60gfwjyW1/dQPjOzn9N394zd2FJoFHwdq9Qs0wBug\nspULZVNRxq7veq/fzwIDAQAB\n-----END PUBLIC KEY-----`
	PemDecodedKey               = `-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHFr+KICms+tuT1OXJwhCUmR2d
KVy7psa8xzElSyzqx7oJyfJ1JZyOzToj9T5SfTIq396agbHJWVfYphNahvZ/7uMX
qHxf+ZH9BL1gk9Y6kCnbM5R60gfwjyW1/dQPjOzn9N394zd2FJoFHwdq9Qs0wBug
spULZVNRxq7veq/fzwIDAQAB
-----END PUBLIC KEY-----`
)

var (
	logger      lager.Logger
	forceUpdate bool
	server      *ghttp.Server
	clock       *fakeclock.FakeClock
	cfg         *config.Config
)

var verifyBody = func(expectedBody string) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		body, err := ioutil.ReadAll(r.Body)
		Expect(err).ToNot(HaveOccurred())

		defer r.Body.Close()
		Expect(string(body)).To(Equal(expectedBody))
	}
}

var verifyLogs = func(reqMessage, resMessage string) {
開發者ID:cloudfoundry-incubator,項目名稱:uaa-go-client,代碼行數:31,代碼來源:client_suite_test.go

示例3:

	"code.cloudfoundry.org/voldriver/voldriverfakes"
	"code.cloudfoundry.org/volman/vollocal"
	"code.cloudfoundry.org/volman/volmanfakes"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"
)

var _ = Describe("Driver Syncer", func() {
	var (
		logger *lagertest.TestLogger

		scanInterval time.Duration

		fakeClock         *fakeclock.FakeClock
		fakeDriverFactory *volmanfakes.FakeDriverFactory

		registry vollocal.DriverRegistry
		syncer   vollocal.DriverSyncer
		process  ifrit.Process

		fakeDriver *voldriverfakes.FakeDriver

		driverName string
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("driver-syncer-test")

		fakeClock = fakeclock.NewFakeClock(time.Unix(123, 456))
		fakeDriverFactory = new(volmanfakes.FakeDriverFactory)

		scanInterval = 10 * time.Second
開發者ID:cloudfoundry-incubator,項目名稱:volman,代碼行數:32,代碼來源:driver_syncer_test.go

示例4:

	Context("when signalled", func() {
		It("deregisters the given service before exiting", func() {
			ginkgomon.Interrupt(registrationProcess)
			services, err := consulClient.Agent().Services()
			Expect(err).NotTo(HaveOccurred())
			Expect(services).ToNot(HaveKey(registration.ID))
		})
	})
})

var _ = Describe("Service Registration Unit Tests", func() {
	var (
		client *fakes.FakeClient
		agent  *fakes.FakeAgent
		logger lager.Logger
		clock  *fakeclock.FakeClock

		registration        *api.AgentServiceRegistration
		registrationRunner  ifrit.Runner
		registrationProcess ifrit.Process
	)

	BeforeEach(func() {
		var fakeComponents *fakes.FakeClientComponents
		client, fakeComponents = fakes.NewFakeClient()
		agent = fakeComponents.Agent
		logger = lagertest.NewTestLogger("test")
		clock = fakeclock.NewFakeClock(time.Now())

		registration = &api.AgentServiceRegistration{
			ID:      "test-id",
			Name:    "Test-Service",
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:32,代碼來源:registration_runner_test.go

示例5:

	"code.cloudfoundry.org/lager/lagertest"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/ginkgomon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gbytes"
)

var _ = Describe("Presence", func() {
	var (
		presenceKey   string
		presenceValue []byte

		consulClient consuladapter.Client

		presenceRunner             ifrit.Runner
		presenceProcess            ifrit.Process
		retryInterval, presenceTTL time.Duration
		logger                     lager.Logger
		clock                      *fakeclock.FakeClock
	)

	getPresenceValue := func() ([]byte, error) {
		kvPair, _, err := consulClient.KV().Get(presenceKey, nil)
		if err != nil {
			return nil, err
		}

		if kvPair == nil || kvPair.Session == "" {
			return nil, consuladapter.NewKeyNotFoundError(presenceKey)
		}
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:32,代碼來源:presence_test.go

示例6:

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	. "github.com/onsi/gomega/gbytes"
)

var _ = Describe("Lock", func() {
	var (
		lockKey              string
		lockHeldMetricName   string
		lockUptimeMetricName string
		lockValue            []byte

		consulClient consuladapter.Client

		lockRunner    ifrit.Runner
		lockProcess   ifrit.Process
		retryInterval time.Duration
		lockTTL       time.Duration
		logger        lager.Logger

		sender *fake.FakeMetricSender
		clock  *fakeclock.FakeClock
	)

	getLockValue := func() ([]byte, error) {
		kvPair, _, err := consulClient.KV().Get(lockKey, nil)
		if err != nil {
			return nil, err
		}
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:29,代碼來源:lock_test.go

示例7:

	"code.cloudfoundry.org/bbs/converger"
	"code.cloudfoundry.org/bbs/converger/fake_controllers"
)

const aBit = 100 * time.Millisecond

var _ = Describe("ConvergerProcess", func() {
	var (
		fakeLrpConvergenceController *fake_controllers.FakeLrpConvergenceController
		fakeTaskController           *fake_controllers.FakeTaskController
		fakeBBSServiceClient         *fake_bbs.FakeServiceClient
		logger                       *lagertest.TestLogger
		fakeClock                    *fakeclock.FakeClock
		convergeRepeatInterval       time.Duration
		kickTaskDuration             time.Duration
		expirePendingTaskDuration    time.Duration
		expireCompletedTaskDuration  time.Duration

		process ifrit.Process

		waitEvents chan<- models.CellEvent
		waitErrs   chan<- error
	)

	BeforeEach(func() {
		fakeLrpConvergenceController = new(fake_controllers.FakeLrpConvergenceController)
		fakeTaskController = new(fake_controllers.FakeTaskController)
		fakeBBSServiceClient = new(fake_bbs.FakeServiceClient)
		logger = lagertest.NewTestLogger("test")
		fakeClock = fakeclock.NewFakeClock(time.Now())
開發者ID:cloudfoundry,項目名稱:bbs,代碼行數:30,代碼來源:converger_test.go

示例8:

	"time"

	"code.cloudfoundry.org/clock/fakeclock"

	"github.com/Sirupsen/logrus"
	"github.com/ice-stuff/clique/scheduler"
	"github.com/ice-stuff/clique/scheduler/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Scheduler", func() {
	var (
		sched        *scheduler.Scheduler
		logger       *logrus.Logger
		taskSelector *fakes.FakeTaskSelector
		csSleep      time.Duration
		clk          *fakeclock.FakeClock
	)

	BeforeEach(func() {
		logger = &logrus.Logger{
			Out:       GinkgoWriter,
			Level:     logrus.DebugLevel,
			Formatter: new(logrus.TextFormatter),
		}
		taskSelector = new(fakes.FakeTaskSelector)
		csSleep = time.Millisecond * 5
		t, err := time.Parse(time.RFC3339, "2015-11-24T06:30:00+00:00")
		Expect(err).NotTo(HaveOccurred())
		clk = fakeclock.NewFakeClock(t)
開發者ID:glestaris,項目名稱:clique,代碼行數:31,代碼來源:scheduler_test.go


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