github.com/xmidt-org/webpa-common@v1.11.9/xhttp/fanout/mocks_test.go (about) 1 package fanout 2 3 import ( 4 "fmt" 5 "net/http" 6 "net/url" 7 8 "github.com/stretchr/testify/mock" 9 ) 10 11 type mockEndpoints struct { 12 mock.Mock 13 } 14 15 func (m *mockEndpoints) FanoutURLs(original *http.Request) ([]*url.URL, error) { 16 arguments := m.Called(original) 17 first, _ := arguments.Get(0).([]*url.URL) 18 return first, arguments.Error(1) 19 } 20 21 // generateEndpoints creates a FixedEndpoints with generated base URLs 22 func generateEndpoints(count int) FixedEndpoints { 23 fe := make(FixedEndpoints, count) 24 for i := 0; i < count; i++ { 25 fe[i] = &url.URL{ 26 Scheme: "http", 27 Host: fmt.Sprintf("host-%d.webpa.net:8080", i), 28 } 29 } 30 31 return fe 32 }