本文整理汇总了Golang中github.com/juju/juju/testing.NonZeroTime函数的典型用法代码示例。如果您正苦于以下问题:Golang NonZeroTime函数的具体用法?Golang NonZeroTime怎么用?Golang NonZeroTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NonZeroTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestMetricsAcrossEnvironments
func (s *CrossModelMetricSuite) TestMetricsAcrossEnvironments(c *gc.C) {
now := s.State.NowToTheSecond().Add(-48 * time.Hour)
m := state.Metric{"pings", "5", now}
m1, err := s.models[0].state.AddMetrics(
state.BatchParam{
UUID: utils.MustNewUUID().String(),
Created: now,
CharmURL: s.models[0].meteredCharm.URL().String(),
Metrics: []state.Metric{m},
Unit: s.models[0].unit.UnitTag(),
},
)
c.Assert(err, jc.ErrorIsNil)
m2, err := s.models[1].state.AddMetrics(
state.BatchParam{
UUID: utils.MustNewUUID().String(),
Created: now,
CharmURL: s.models[1].meteredCharm.URL().String(),
Metrics: []state.Metric{m},
Unit: s.models[1].unit.UnitTag(),
},
)
c.Assert(err, jc.ErrorIsNil)
batches, err := s.State.AllMetricBatches()
c.Assert(err, jc.ErrorIsNil)
c.Assert(batches, gc.HasLen, 2)
unsent, err := s.models[0].state.CountOfUnsentMetrics()
c.Assert(err, jc.ErrorIsNil)
c.Assert(unsent, gc.Equals, 1)
toSend, err := s.models[0].state.MetricsToSend(10)
c.Assert(err, jc.ErrorIsNil)
c.Assert(toSend, gc.HasLen, 1)
err = m1.SetSent(testing.NonZeroTime().Add(-25 * time.Hour))
c.Assert(err, jc.ErrorIsNil)
err = m2.SetSent(testing.NonZeroTime().Add(-25 * time.Hour))
c.Assert(err, jc.ErrorIsNil)
sent, err := s.models[0].state.CountOfSentMetrics()
c.Assert(err, jc.ErrorIsNil)
c.Assert(sent, gc.Equals, 1)
err = s.models[0].state.CleanupOldMetrics()
c.Assert(err, jc.ErrorIsNil)
// The metric from model s.models[1] should still be in place.
batches, err = s.State.AllMetricBatches()
c.Assert(err, jc.ErrorIsNil)
c.Assert(batches, gc.HasLen, 1)
}
开发者ID:bac,项目名称:juju,代码行数:54,代码来源:metrics_test.go
示例2: TestCleanupMetrics
func (s *MetricSuite) TestCleanupMetrics(c *gc.C) {
oldTime := testing.NonZeroTime().Add(-(time.Hour * 25))
now := testing.NonZeroTime()
m := state.Metric{"pings", "5", oldTime}
oldMetric1, err := s.State.AddMetrics(
state.BatchParam{
UUID: utils.MustNewUUID().String(),
Created: now,
CharmURL: s.meteredCharm.URL().String(),
Metrics: []state.Metric{m},
Unit: s.unit.UnitTag(),
},
)
c.Assert(err, jc.ErrorIsNil)
oldMetric1.SetSent(testing.NonZeroTime().Add(-25 * time.Hour))
oldMetric2, err := s.State.AddMetrics(
state.BatchParam{
UUID: utils.MustNewUUID().String(),
Created: now,
CharmURL: s.meteredCharm.URL().String(),
Metrics: []state.Metric{m},
Unit: s.unit.UnitTag(),
},
)
c.Assert(err, jc.ErrorIsNil)
oldMetric2.SetSent(testing.NonZeroTime().Add(-25 * time.Hour))
m = state.Metric{"pings", "5", now}
newMetric, err := s.State.AddMetrics(
state.BatchParam{
UUID: utils.MustNewUUID().String(),
Created: now,
CharmURL: s.meteredCharm.URL().String(),
Metrics: []state.Metric{m},
Unit: s.unit.UnitTag(),
},
)
c.Assert(err, jc.ErrorIsNil)
newMetric.SetSent(testing.NonZeroTime())
err = s.State.CleanupOldMetrics()
c.Assert(err, jc.ErrorIsNil)
_, err = s.State.MetricBatch(newMetric.UUID())
c.Assert(err, jc.ErrorIsNil)
_, err = s.State.MetricBatch(oldMetric1.UUID())
c.Assert(err, jc.Satisfies, errors.IsNotFound)
_, err = s.State.MetricBatch(oldMetric2.UUID())
c.Assert(err, jc.Satisfies, errors.IsNotFound)
}
开发者ID:bac,项目名称:juju,代码行数:52,代码来源:metrics_test.go
示例3: addMetadataDoc
func (s *ImageSuite) addMetadataDoc(c *gc.C, kind, series, arch string, size int64, checksum, path, sourceURL string) {
doc := struct {
Id string `bson:"_id"`
ModelUUID string `bson:"modelUUID"`
Kind string `bson:"kind"`
Series string `bson:"series"`
Arch string `bson:"arch"`
Size int64 `bson:"size"`
SHA256 string `bson:"sha256,omitempty"`
Path string `bson:"path"`
Created time.Time `bson:"created"`
SourceURL string `bson:"sourceurl"`
}{
Id: fmt.Sprintf("my-uuid-%s-%s-%s", kind, series, arch),
ModelUUID: "my-uuid",
Kind: kind,
Series: series,
Arch: arch,
Size: size,
SHA256: checksum,
Path: path,
Created: testing.NonZeroTime(),
SourceURL: sourceURL,
}
err := s.metadataCollection.Insert(&doc)
c.Assert(err, gc.IsNil)
}
开发者ID:bac,项目名称:juju,代码行数:27,代码来源:image_test.go
示例4: TestSetCharmStoreResourceOkay
func (s *ResourcePersistenceSuite) TestSetCharmStoreResourceOkay(c *gc.C) {
lastPolled := coretesting.NonZeroTime().UTC()
applicationname := "a-application"
res, doc := newPersistenceResource(c, applicationname, "spam")
expected := doc // a copy
expected.DocID += "#charmstore"
expected.Username = ""
expected.Timestamp = coretesting.ZeroTime()
expected.StoragePath = ""
expected.LastPolled = lastPolled
p := NewResourcePersistence(s.base)
ignoredErr := errors.New("<never reached>")
s.stub.SetErrors(nil, nil, nil, ignoredErr)
err := p.SetCharmStoreResource(res.ID, res.ApplicationID, res.Resource.Resource, lastPolled)
c.Assert(err, jc.ErrorIsNil)
s.stub.CheckCallNames(c,
"Run",
"ApplicationExistsOps",
"RunTransaction",
)
s.stub.CheckCall(c, 2, "RunTransaction", []txn.Op{{
C: "resources",
Id: "resource#a-application/spam#charmstore",
Assert: txn.DocMissing,
Insert: &expected,
}, {
C: "application",
Id: "a-application",
Assert: txn.DocExists,
}})
}
开发者ID:bac,项目名称:juju,代码行数:33,代码来源:resources_persistence_test.go
示例5: TestPruneLogsByTime
func (s *LogsSuite) TestPruneLogsByTime(c *gc.C) {
dbLogger := state.NewDbLogger(s.State, names.NewMachineTag("22"), jujuversion.Current)
defer dbLogger.Close()
log := func(t time.Time, msg string) {
err := dbLogger.Log(t, "module", "loc", loggo.INFO, msg)
c.Assert(err, jc.ErrorIsNil)
}
now := coretesting.NonZeroTime()
maxLogTime := now.Add(-time.Minute)
log(now, "keep")
log(maxLogTime.Add(time.Second), "keep")
log(maxLogTime, "keep")
log(maxLogTime.Add(-time.Second), "prune")
log(maxLogTime.Add(-(2 * time.Second)), "prune")
noPruneMB := 100
err := state.PruneLogs(s.State, maxLogTime, noPruneMB)
c.Assert(err, jc.ErrorIsNil)
// After pruning there should just be 3 "keep" messages left.
var docs []bson.M
err = s.logsColl.Find(nil).All(&docs)
c.Assert(err, jc.ErrorIsNil)
c.Assert(docs, gc.HasLen, 3)
for _, doc := range docs {
c.Assert(doc["x"], gc.Equals, "keep")
}
}
开发者ID:bac,项目名称:juju,代码行数:29,代码来源:logs_test.go
示例6: TestTimeFiltering
func (s *LogTailerSuite) TestTimeFiltering(c *gc.C) {
// Add 10 logs that shouldn't be returned.
threshT := coretesting.NonZeroTime()
s.writeLogsT(c,
threshT.Add(-5*time.Second), threshT.Add(-time.Millisecond), 5,
logTemplate{Message: "dont want"},
)
// Add 5 logs that should be returned.
want := logTemplate{Message: "want"}
s.writeLogsT(c, threshT, threshT.Add(5*time.Second), 5, want)
tailer, err := state.NewLogTailer(s.otherState, &state.LogTailerParams{
StartTime: threshT,
Oplog: s.oplogColl,
})
c.Assert(err, jc.ErrorIsNil)
defer tailer.Stop()
s.assertTailer(c, tailer, 5, want)
// Write more logs. These will be read from the the oplog.
want2 := logTemplate{Message: "want 2"}
s.writeLogsT(c, threshT.Add(6*time.Second), threshT.Add(10*time.Second), 5, want2)
s.assertTailer(c, tailer, 5, want2)
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:logs_test.go
示例7: TestAddUser
func (s *UserSuite) TestAddUser(c *gc.C) {
name := "f00-Bar.ram77"
displayName := "Display"
password := "password"
creator := "admin"
now := testing.NonZeroTime().Round(time.Second).UTC()
user, err := s.State.AddUser(name, displayName, password, creator)
c.Assert(err, jc.ErrorIsNil)
c.Assert(user, gc.NotNil)
c.Assert(user.Name(), gc.Equals, name)
c.Assert(user.DisplayName(), gc.Equals, displayName)
c.Assert(user.PasswordValid(password), jc.IsTrue)
c.Assert(user.CreatedBy(), gc.Equals, creator)
c.Assert(user.DateCreated().After(now) ||
user.DateCreated().Equal(now), jc.IsTrue)
lastLogin, err := user.LastLogin()
c.Assert(err, jc.Satisfies, state.IsNeverLoggedInError)
c.Assert(lastLogin, gc.DeepEquals, time.Time{})
user, err = s.State.User(user.UserTag())
c.Assert(err, jc.ErrorIsNil)
c.Assert(user, gc.NotNil)
c.Assert(user.Name(), gc.Equals, name)
c.Assert(user.DisplayName(), gc.Equals, displayName)
c.Assert(user.PasswordValid(password), jc.IsTrue)
c.Assert(user.CreatedBy(), gc.Equals, creator)
c.Assert(user.DateCreated().After(now) ||
user.DateCreated().Equal(now), jc.IsTrue)
lastLogin, err = user.LastLogin()
c.Assert(err, jc.Satisfies, state.IsNeverLoggedInError)
c.Assert(lastLogin, gc.DeepEquals, time.Time{})
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:user_test.go
示例8: TestFunctional
func (s *ResourcesSuite) TestFunctional(c *gc.C) {
ch := s.ConnSuite.AddTestingCharm(c, "wordpress")
s.ConnSuite.AddTestingService(c, "a-application", ch)
st, err := s.State.Resources()
c.Assert(err, jc.ErrorIsNil)
resources, err := st.ListResources("a-application")
c.Assert(err, jc.ErrorIsNil)
c.Check(resources.Resources, gc.HasLen, 0)
data := "spamspamspam"
res := newResource(c, "spam", data)
file := bytes.NewBufferString(data)
_, err = st.SetResource("a-application", res.Username, res.Resource, file)
c.Assert(err, jc.ErrorIsNil)
csResources := []charmresource.Resource{res.Resource}
err = st.SetCharmStoreResources("a-application", csResources, testing.NonZeroTime())
c.Assert(err, jc.ErrorIsNil)
resources, err = st.ListResources("a-application")
c.Assert(err, jc.ErrorIsNil)
res.Timestamp = resources.Resources[0].Timestamp
c.Check(resources, jc.DeepEquals, resource.ServiceResources{
Resources: []resource.Resource{res},
CharmStoreResources: csResources,
})
// TODO(ericsnow) Add more as state.Resources grows more functionality.
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:resources_test.go
示例9: TestPruneStatusHistoryBySize
func (s *StatusHistorySuite) TestPruneStatusHistoryBySize(c *gc.C) {
clock := testing.NewClock(coretesting.NonZeroTime())
err := s.State.SetClockForTesting(clock)
c.Assert(err, jc.ErrorIsNil)
service := s.Factory.MakeApplication(c, nil)
unit := s.Factory.MakeUnit(c, &factory.UnitParams{Application: service})
state.PrimeUnitStatusHistory(c, clock, unit, status.Active, 20000, 1000, nil)
history, err := unit.StatusHistory(status.StatusHistoryFilter{Size: 25000})
c.Assert(err, jc.ErrorIsNil)
c.Logf("%d\n", len(history))
c.Assert(history, gc.HasLen, 20001)
err = state.PruneStatusHistory(s.State, 0, 1)
c.Assert(err, jc.ErrorIsNil)
history, err = unit.StatusHistory(status.StatusHistoryFilter{Size: 25000})
c.Assert(err, jc.ErrorIsNil)
historyLen := len(history)
// When writing this test, the size was 6670 for about 0,00015 MB per entry
// but that is a size that can most likely change so I wont risk a flaky test
// here, enough to say that if this size suddenly is no longer less than
// half its good reason for suspicion.
c.Assert(historyLen, jc.LessThan, 10000)
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:status_history_test.go
示例10: setStored
func (s *backupsSuite) setStored(id string) *time.Time {
s.Storage.ID = id
s.Storage.Meta = backupstesting.NewMetadataStarted()
s.Storage.Meta.SetID(id)
stored := testing.NonZeroTime().UTC()
s.Storage.Meta.SetStored(&stored)
return &stored
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:backups_test.go
示例11: TestPruneLogsBySize
func (s *LogsSuite) TestPruneLogsBySize(c *gc.C) {
// Set up 3 models and generate different amounts of logs
// for them.
now := coretesting.NonZeroTime().Truncate(time.Millisecond)
s0 := s.State
startingLogsS0 := 10
s.generateLogs(c, s0, now, startingLogsS0)
s1 := s.Factory.MakeModel(c, nil)
defer s1.Close()
startingLogsS1 := 10000
s.generateLogs(c, s1, now, startingLogsS1)
s2 := s.Factory.MakeModel(c, nil)
defer s2.Close()
startingLogsS2 := 12000
s.generateLogs(c, s2, now, startingLogsS2)
// Prune logs collection back to 1 MiB.
tsNoPrune := coretesting.NonZeroTime().Add(-3 * 24 * time.Hour)
err := state.PruneLogs(s.State, tsNoPrune, 1)
c.Assert(err, jc.ErrorIsNil)
// Logs for first env should not be touched.
c.Assert(s.countLogs(c, s0), gc.Equals, startingLogsS0)
// Logs for second env should be pruned.
c.Assert(s.countLogs(c, s1), jc.LessThan, startingLogsS1)
// Logs for third env should be pruned to a similar level as
// second env.
c.Assert(s.countLogs(c, s2), jc.LessThan, startingLogsS1)
// Ensure that the latest log records are still there.
assertLatestTs := func(st *state.State) {
var doc bson.M
err := s.logsColl.Find(bson.M{"e": st.ModelUUID()}).Sort("-t").One(&doc)
c.Assert(err, jc.ErrorIsNil)
c.Assert(doc["t"], gc.Equals, now.UnixNano())
}
assertLatestTs(s0)
assertLatestTs(s1)
assertLatestTs(s2)
}
开发者ID:bac,项目名称:juju,代码行数:45,代码来源:logs_test.go
示例12: assertMetricsManagerAmberState
func assertMetricsManagerAmberState(c *gc.C, metricsManager *state.MetricsManager) {
err := metricsManager.SetLastSuccessfulSend(testing.NonZeroTime())
c.Assert(err, jc.ErrorIsNil)
for i := 0; i < 3; i++ {
err := metricsManager.IncrementConsecutiveErrors()
c.Assert(err, jc.ErrorIsNil)
}
status := metricsManager.MeterStatus()
c.Assert(status.Code, gc.Equals, state.MeterAmber)
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:meterstatus_test.go
示例13: TestUpdateLastLogin
func (s *UserSuite) TestUpdateLastLogin(c *gc.C) {
now := testing.NonZeroTime().Round(time.Second).UTC()
user := s.Factory.MakeUser(c, nil)
err := user.UpdateLastLogin()
c.Assert(err, jc.ErrorIsNil)
lastLogin, err := user.LastLogin()
c.Assert(err, jc.ErrorIsNil)
c.Assert(lastLogin.After(now) ||
lastLogin.Equal(now), jc.IsTrue)
}
开发者ID:bac,项目名称:juju,代码行数:10,代码来源:user_test.go
示例14: assertMetricsManagerRedState
// TODO (mattyw) This function could be moved into a metricsmanager testing package.
func assertMetricsManagerRedState(c *gc.C, metricsManager *state.MetricsManager) {
// To enter the red state we need to set a last successful send as over 1 week ago
err := metricsManager.SetLastSuccessfulSend(testing.NonZeroTime().Add(-8 * 24 * time.Hour))
c.Assert(err, jc.ErrorIsNil)
for i := 0; i < 3; i++ {
err := metricsManager.IncrementConsecutiveErrors()
c.Assert(err, jc.ErrorIsNil)
}
status := metricsManager.MeterStatus()
c.Assert(status.Code, gc.Equals, state.MeterRed)
}
开发者ID:bac,项目名称:juju,代码行数:12,代码来源:meterstatus_test.go
示例15: TestDoc2BasicResourceCharmstoreFull
func (s *ResourcesMongoSuite) TestDoc2BasicResourceCharmstoreFull(c *gc.C) {
applicationID := "a-application"
docID := applicationResourceID("spam")
content := "some data\n..."
fp, err := charmresource.GenerateFingerprint(strings.NewReader(content))
c.Assert(err, jc.ErrorIsNil)
now := coretesting.NonZeroTime()
res, err := doc2basicResource(resourceDoc{
DocID: docID,
ID: "a-application/spam",
PendingID: "some-unique-ID",
ApplicationID: applicationID,
Name: "spam",
Type: "file",
Path: "spam.tgz",
Description: "you need this!",
Origin: "store",
Revision: 5,
Fingerprint: fp.Bytes(),
Size: int64(len(content)),
Username: "a-user",
Timestamp: now,
StoragePath: "application-a-application/resources/spam",
})
c.Assert(err, jc.ErrorIsNil)
c.Check(res, jc.DeepEquals, resource.Resource{
Resource: charmresource.Resource{
Meta: charmresource.Meta{
Name: "spam",
Type: charmresource.TypeFile,
Path: "spam.tgz",
Description: "you need this!",
},
Origin: charmresource.OriginStore,
Revision: 5,
Fingerprint: fp,
Size: int64(len(content)),
},
ID: "a-application/spam",
PendingID: "some-unique-ID",
ApplicationID: applicationID,
Username: "a-user",
Timestamp: now,
})
}
开发者ID:bac,项目名称:juju,代码行数:52,代码来源:resources_mongo_test.go
示例16: TestDoc2Resource
func (s *ResourcesMongoSuite) TestDoc2Resource(c *gc.C) {
applicationID := "a-application"
docID := pendingResourceID("spam", "some-unique-ID-001")
content := "some data\n..."
fp, err := charmresource.GenerateFingerprint(strings.NewReader(content))
c.Assert(err, jc.ErrorIsNil)
now := coretesting.NonZeroTime()
res, err := doc2resource(resourceDoc{
DocID: docID,
ID: "a-application/spam",
PendingID: "some-unique-ID-001",
ApplicationID: applicationID,
Name: "spam",
Type: "file",
Path: "spam.tgz",
Origin: "upload",
Fingerprint: fp.Bytes(),
Size: int64(len(content)),
Username: "a-user",
Timestamp: now,
StoragePath: "application-a-application/resources/spam-some-unique-ID-001",
})
c.Assert(err, jc.ErrorIsNil)
c.Check(res, jc.DeepEquals, storedResource{
Resource: resource.Resource{
Resource: charmresource.Resource{
Meta: charmresource.Meta{
Name: "spam",
Type: charmresource.TypeFile,
Path: "spam.tgz",
},
Origin: charmresource.OriginUpload,
Fingerprint: fp,
Size: int64(len(content)),
},
ID: "a-application/spam",
PendingID: "some-unique-ID-001",
ApplicationID: applicationID,
Username: "a-user",
Timestamp: now,
},
storagePath: "application-a-application/resources/spam-some-unique-ID-001",
})
}
开发者ID:bac,项目名称:juju,代码行数:50,代码来源:resources_mongo_test.go
示例17: TestCountMetrics
// TestCountMetrics asserts the correct values are returned
// by CountOfUnsentMetrics and CountOfSentMetrics.
func (s *MetricSuite) TestCountMetrics(c *gc.C) {
now := testing.NonZeroTime()
m := []state.Metric{{Key: "pings", Value: "123", Time: now}}
s.Factory.MakeMetric(c, &factory.MetricParams{Unit: s.unit, Sent: false, Time: &now, Metrics: m})
s.Factory.MakeMetric(c, &factory.MetricParams{Unit: s.unit, Sent: false, Time: &now, Metrics: m})
s.Factory.MakeMetric(c, &factory.MetricParams{Unit: s.unit, Sent: true, Time: &now, Metrics: m})
sent, err := s.State.CountOfSentMetrics()
c.Assert(err, jc.ErrorIsNil)
c.Assert(sent, gc.Equals, 1)
unsent, err := s.State.CountOfUnsentMetrics()
c.Assert(err, jc.ErrorIsNil)
c.Assert(unsent, gc.Equals, 2)
c.Assert(unsent+sent, gc.Equals, 3)
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:metrics_test.go
示例18: TestPutAuditEntry_PersistAuditEntry
func (*AuditSuite) TestPutAuditEntry_PersistAuditEntry(c *gc.C) {
requested := audit.AuditEntry{
JujuServerVersion: version.MustParse("1.0.0"),
ModelUUID: utils.MustNewUUID().String(),
Timestamp: coretesting.NonZeroTime().UTC(),
RemoteAddress: "8.8.8.8",
OriginType: "user",
OriginName: "bob",
Operation: "status",
Data: map[string]interface{}{
"a": "b",
"$a.b": map[string]interface{}{
"b.$a": "c",
},
},
}
var insertDocsCalled bool
insertDocs := func(collectionName string, docs ...interface{}) error {
insertDocsCalled = true
c.Check(collectionName, gc.Equals, "audit.log")
c.Assert(docs, gc.HasLen, 1)
serializedAuditDoc, err := bson.Marshal(docs[0])
c.Assert(err, jc.ErrorIsNil)
requestedTimeBlob, err := requested.Timestamp.MarshalText()
c.Assert(err, jc.ErrorIsNil)
c.Check(string(serializedAuditDoc), jc.BSONEquals, map[string]interface{}{
"juju-server-version": requested.JujuServerVersion,
"model-uuid": requested.ModelUUID,
"timestamp": string(requestedTimeBlob),
"remote-address": "8.8.8.8",
"origin-type": requested.OriginType,
"origin-name": requested.OriginName,
"operation": requested.Operation,
"data": mongoutils.EscapeKeys(requested.Data),
})
return nil
}
putAuditEntry := stateaudit.PutAuditEntryFn("audit.log", insertDocs)
err := putAuditEntry(requested)
c.Assert(err, jc.ErrorIsNil)
c.Assert(insertDocsCalled, jc.IsTrue)
}
开发者ID:bac,项目名称:juju,代码行数:50,代码来源:audit_test.go
示例19: TestMeterStatusWatcherRespondsToMetricsManager
func (s *MeterStateSuite) TestMeterStatusWatcherRespondsToMetricsManager(c *gc.C) {
mm, err := s.State.MetricsManager()
c.Assert(err, jc.ErrorIsNil)
watcher := s.unit.WatchMeterStatus()
assertMeterStatusChanged(c, watcher)
err = mm.SetLastSuccessfulSend(testing.NonZeroTime())
c.Assert(err, jc.ErrorIsNil)
for i := 0; i < 3; i++ {
err := mm.IncrementConsecutiveErrors()
c.Assert(err, jc.ErrorIsNil)
}
status := mm.MeterStatus()
c.Assert(status.Code, gc.Equals, state.MeterAmber)
assertMeterStatusChanged(c, watcher)
}
开发者ID:bac,项目名称:juju,代码行数:15,代码来源:meterstatus_test.go
示例20: TestSaveMetadataWithDateCreated
func (s *cloudImageMetadataSuite) TestSaveMetadataWithDateCreated(c *gc.C) {
attrs := cloudimagemetadata.MetadataAttributes{
Stream: "stream",
Region: "region-test",
Version: "14.04",
Series: "trusty",
Arch: "arch",
VirtType: "virtType-test",
RootStorageType: "rootStorageType-test",
Source: "test",
}
now := coretesting.NonZeroTime().UnixNano()
metadata := cloudimagemetadata.Metadata{attrs, 0, "1", now}
s.assertRecordMetadata(c, metadata)
s.assertMetadataRecorded(c, cloudimagemetadata.MetadataAttributes{}, metadata)
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:image_test.go
注:本文中的github.com/juju/juju/testing.NonZeroTime函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论