github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/modules/host/dependencies_test.go (about) 1 package host 2 3 import ( 4 "net" 5 6 "SiaPrime/modules" 7 ) 8 9 type ( 10 // dependencyCustomLookupIP is a dependency that enables mocking of the 11 // net.LookupIP method for testing. 12 dependencyCustomLookupIP struct { 13 modules.ProductionDependencies 14 lookupIP func(string) ([]net.IP, error) 15 } 16 ) 17 18 // LookupIP calls the custom lookupIP method the struct was created with. 19 func (d *dependencyCustomLookupIP) LookupIP(host string) ([]net.IP, error) { 20 return d.lookupIP(host) 21 } 22 23 // NewDependencyCustomLookupIP creates a dependencyCustomLookupIP from the 24 // provided lookupIP method. 25 func NewDependencyCustomLookupIP(lookupIP func(string) ([]net.IP, error)) *dependencyCustomLookupIP { 26 return &dependencyCustomLookupIP{ 27 lookupIP: lookupIP, 28 } 29 }