Skip to content

Commit e0ba363

Browse files
committed
add deprecated methods
1 parent 32fe5eb commit e0ba363

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

env.go

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ func (e *EnvT) T() T {
8383
// opt - fixture options, nil for default options.
8484
// f - callback - fixture body.
8585
// Cache guarantee for call f exactly once for same Cache called and params combination.
86+
// Deprecated: will be removed in next versions.
87+
// Use EnvT.CacheResult instead
8688
func (e *EnvT) Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackFunc) interface{} {
8789
return e.cache(cacheKey, opt, f)
8890
}
@@ -99,6 +101,8 @@ func (e *EnvT) Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbac
99101
// f - callback - fixture body.
100102
// cleanup, returned from f called while fixture cleanup
101103
// Cache guarantee for call f exactly once for same Cache called and params combination.
104+
// Deprecated: will be removed in next versions.
105+
// Use EnvT.CacheResult instead
102106
func (e *EnvT) CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackWithCleanupFunc) interface{} {
103107
if opt == nil {
104108
opt = &FixtureOptions{}
@@ -119,6 +123,9 @@ func (e *EnvT) CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f Fix
119123
return e.cache(cacheKey, opt, fWithoutCleanup)
120124
}
121125

126+
// CacheResult call f callback once and cache result (ok and error),
127+
// then return same result for all calls of the callback without additional calls
128+
// f with same options calls max once per test (or defined test scope)
122129
func (e *EnvT) CacheResult(f FixtureFunction, options ...CacheOptions) interface{} {
123130
var cacheOptions CacheOptions
124131
switch len(options) {

interface.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ type Env interface {
1414
// Cache result of f calls
1515
// f call exactly once for every combination of scope and params
1616
// params must be json serializable (deserialize not need)
17-
// Deprecated: Use CacheResult
17+
// Deprecated: will be removed in next versions
18+
// Use Env.CacheResult instead.
1819
Cache(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackFunc) interface{}
1920

2021
// CacheWithCleanup cache result of f calls
2122
// f call exactly once for every combination of scope and params
2223
// params must be json serializable (deserialize not need)
23-
// Deprecated: Use CacheResult
24+
// Deprecated: will be removed in next versions
25+
// Use Env.CacheResult instead.
2426
CacheWithCleanup(cacheKey interface{}, opt *FixtureOptions, f FixtureCallbackWithCleanupFunc) interface{}
2527
}
2628

0 commit comments

Comments
 (0)