WithFetcher overrides the function used to fetch the catalog from the network. It is primarily a test seam: callers can stub the network out (and observe whether a fetch was attempted) without mutating package-level state, which keeps such tests safe to run in parallel.
(fn fetcher)
| 77 | // (and observe whether a fetch was attempted) without mutating package-level |
| 78 | // state, which keeps such tests safe to run in parallel. |
| 79 | func WithFetcher(fn fetcher) Opt { |
| 80 | return func(o *storeOptions) { |
| 81 | o.fetch = fn |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // WithKnownProvider restricts which provider names may trigger an outbound |
| 86 | // fetch of the models.dev catalog. The predicate should report whether a |
no outgoing calls