diff --git a/env.go b/env.go index 546601d..e66c7ca 100644 --- a/env.go +++ b/env.go @@ -83,6 +83,8 @@ func (e *EnvT) T() T { // opt - fixture options, nil for default options. // f - callback - fixture body. // Cache guarantee for call f exactly once for same Cache called and params combination. +// Deprecated: will be removed in next versions. +// Use EnvT.CacheResult instead func (e *EnvT) Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackFunc) interface{} { return e.cache(cacheKey, opt, f) } @@ -99,6 +101,8 @@ func (e *EnvT) Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbac // f - callback - fixture body. // cleanup, returned from f called while fixture cleanup // Cache guarantee for call f exactly once for same Cache called and params combination. +// Deprecated: will be removed in next versions. +// Use EnvT.CacheResult instead func (e *EnvT) CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackWithCleanupFunc) interface{} { if opt == nil { opt = &FixtureOptions{} @@ -119,6 +123,9 @@ func (e *EnvT) CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f Fix return e.cache(cacheKey, opt, fWithoutCleanup) } +// CacheResult call f callback once and cache result (ok and error), +// then return same result for all calls of the callback without additional calls +// f with same options calls max once per test (or defined test scope) func (e *EnvT) CacheResult(f FixtureFunction, options ...CacheOptions) interface{} { var cacheOptions CacheOptions switch len(options) { diff --git a/interface.go b/interface.go index a171b3b..cc1870d 100644 --- a/interface.go +++ b/interface.go @@ -14,13 +14,15 @@ type Env interface { // Cache result of f calls // f call exactly once for every combination of scope and params // params must be json serializable (deserialize not need) - // Deprecated: Use CacheResult + // Deprecated: will be removed in next versions + // Use Env.CacheResult instead. Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackFunc) interface{} // CacheWithCleanup cache result of f calls // f call exactly once for every combination of scope and params // params must be json serializable (deserialize not need) - // Deprecated: Use CacheResult + // Deprecated: will be removed in next versions + // Use Env.CacheResult instead. CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackWithCleanupFunc) interface{} }