fakeScripter simulates enough of Scripter for unit testing Script behavior. It records which redis commands were invoked and can simulate NOSCRIPT.
| 12 | // fakeScripter simulates enough of Scripter for unit testing Script behavior. |
| 13 | // It records which redis commands were invoked and can simulate NOSCRIPT. |
| 14 | type fakeScripter struct { |
| 15 | mu sync.Mutex |
| 16 | |
| 17 | // call counters |
| 18 | scriptLoadCalls int |
| 19 | evalCalls int |
| 20 | evalShaCalls int |
| 21 | evalROCalls int |
| 22 | evalShaROCalls int |
| 23 | |
| 24 | // behavior controls |
| 25 | hashToReturn string |
| 26 | |
| 27 | // If set, the first EvalSha/EvalShaRO returns a NOSCRIPT error. |
| 28 | failFirstEvalShaWithNoScr bool |
| 29 | failFirstEvalShaROWithNoScr bool |
| 30 | } |
| 31 | |
| 32 | func (f *fakeScripter) ScriptLoad(ctx context.Context, script string) *StringCmd { |
| 33 | f.mu.Lock() |
nothing calls this directly
no outgoing calls
no test coverage detected