-
Notifications
You must be signed in to change notification settings - Fork 198
/
pathHandlerStub.go
44 lines (35 loc) · 1.04 KB
/
pathHandlerStub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package testscommon
import (
"fmt"
)
// PathManagerStub -
type PathManagerStub struct {
PathForEpochCalled func(shardId string, epoch uint32, identifier string) string
PathForStaticCalled func(shardId string, identifier string) string
DatabasePathCalled func() string
}
// PathForEpoch -
func (p *PathManagerStub) PathForEpoch(shardId string, epoch uint32, identifier string) string {
if p.PathForEpochCalled != nil {
return p.PathForEpochCalled(shardId, epoch, identifier)
}
return fmt.Sprintf("Epoch_%d/Shard_%s/%s", epoch, shardId, identifier)
}
// PathForStatic -
func (p *PathManagerStub) PathForStatic(shardId string, identifier string) string {
if p.PathForEpochCalled != nil {
return p.PathForStaticCalled(shardId, identifier)
}
return fmt.Sprintf("Static/Shard_%s/%s", shardId, identifier)
}
// DatabasePath -
func (p *PathManagerStub) DatabasePath() string {
if p.DatabasePathCalled != nil {
return p.DatabasePathCalled()
}
return "db"
}
// IsInterfaceNil -
func (p *PathManagerStub) IsInterfaceNil() bool {
return p == nil
}