MCPcopy Create free account
hub / github.com/gavv/httpexpect / GetTime

Method GetTime

environment.go:421–446  ·  view source on GitHub ↗

GetTime returns value stored in the environment, casted to time.Time. If value does not exist, is not time.Time, reports failure and returns zero time. Example: value := env.GetTime("key")

(key string)

Source from the content-addressed store, hash-verified

419//
420// value := env.GetTime("key")
421func (e *Environment) GetTime(key string) time.Time {
422 opChain := e.chain.enter("GetTime(%q)", key)
423 defer opChain.leave()
424
425 e.mu.RLock()
426 defer e.mu.RUnlock()
427
428 value, ok := envValue(opChain, e.data, key)
429 if !ok {
430 return time.Unix(0, 0)
431 }
432
433 casted, ok := value.(time.Time)
434 if !ok {
435 opChain.fail(AssertionFailure{
436 Type: AssertType,
437 Actual: &AssertionValue{value},
438 Errors: []error{
439 errors.New("expected: time.Time value"),
440 },
441 })
442 return time.Unix(0, 0)
443 }
444
445 return casted
446}
447
448// List returns a sorted slice of keys.
449//

Callers 2

TestEnvironment_NotFoundFunction · 0.80
TestEnvironment_TimeFunction · 0.80

Calls 4

envValueFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failMethod · 0.80

Tested by 2

TestEnvironment_NotFoundFunction · 0.64
TestEnvironment_TimeFunction · 0.64