This commit is contained in:
2025-09-18 05:40:45 -07:00
parent 030ad360c2
commit 7da16e55a9
20 changed files with 843 additions and 219 deletions

View File

@@ -0,0 +1,24 @@
package testutils
import (
"errors"
"io"
"net/url"
"garmin-connect/garth/client"
)
// MockClient simulates API client for tests
type MockClient struct {
RealClient *client.Client
FailEvery int
counter int
}
func (mc *MockClient) ConnectAPI(path string, method string, params url.Values, body io.Reader) ([]byte, error) {
mc.counter++
if mc.FailEvery != 0 && mc.counter%mc.FailEvery == 0 {
return nil, errors.New("simulated error")
}
return mc.RealClient.ConnectAPI(path, method, params, body)
}