Documentation
¶
Overview ¶
Package clienttest fakes the GitHub API for tests.
Index ¶
- func InstantRetries(t *testing.T)
- func JSON(t *testing.T, w http.ResponseWriter, v any)
- func NewServer(t *testing.T) (mux *http.ServeMux, spec client.Spec)
- func Sync(t *testing.T, spec client.Spec, table *schema.Table, cfg SyncConfig) (map[string][]map[string]any, []string)
- func SyncTable(t *testing.T, spec client.Spec, table *schema.Table) map[string][]map[string]any
- func SyncTableWithState(t *testing.T, spec client.Spec, table *schema.Table, st state.Client) map[string][]map[string]any
- func SyncTableWithStateErrors(t *testing.T, spec client.Spec, table *schema.Table, st state.Client) (map[string][]map[string]any, []string)
- func WithApp(t *testing.T, mux *http.ServeMux, spec client.Spec, org string) client.Spec
- type MemState
- type SyncConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstantRetries ¶
InstantRetries makes the clients' retries of transient failures (500, 502, 503, 504 and transport errors on GET) happen without waiting, until the test ends.
func NewServer ¶
NewServer starts an httptest server that is closed when the test ends. The returned Spec has Enterprise.BaseURL/UploadURL pointing at it and AccessToken "test-token". Register handlers on mux with paths as go-github requests them under the enterprise prefix, e.g. "/api/v3/orgs/acme".
func Sync ¶
func Sync(t *testing.T, spec client.Spec, table *schema.Table, cfg SyncConfig) (map[string][]map[string]any, []string)
Sync is the general form of the SyncTable helpers: it syncs table with the settings of cfg and returns the rows per table name and the table of every resolver error reported.
func SyncTable ¶
SyncTable builds a client.Client from spec, syncs table and its relations with the SDK scheduler, and returns the rows per table name. Values are int64, string, time.Time and so on as stored in the Arrow record; JSON columns hold the decoded value (map[string]any, []any, float64, ...) and list-of-string columns a []string. Nulls are nil. The test fails if the sync fails.
func SyncTableWithState ¶
func SyncTableWithState(t *testing.T, spec client.Spec, table *schema.Table, st state.Client) map[string][]map[string]any
SyncTableWithState is SyncTable with an enabled client.StateStore over st, saved after the sync. The test fails if the sync or the save fails.
func SyncTableWithStateErrors ¶
func SyncTableWithStateErrors(t *testing.T, spec client.Spec, table *schema.Table, st state.Client) (map[string][]map[string]any, []string)
SyncTableWithStateErrors is SyncTableWithState that also returns the name of the table of every resolver error the sync reported, once per error.
Types ¶
type MemState ¶
type MemState struct {
// contains filtered or unexported fields
}
MemState is an in-memory state.Client. It is safe for concurrent use and counts calls to Flush.
type SyncConfig ¶
type SyncConfig struct {
// Ctx is the sync's context; context.Background() when nil. When it is
// cancelled during the sync, the scheduler's error is tolerated and the
// state is not saved, as in the plugin.
Ctx context.Context
// State, when not nil, backs an enabled client.StateStore, saved after a
// sync that was not cancelled.
State state.Client
// Store, when not nil, is used instead of a store over State, so the test
// can inspect it afterwards.
Store *client.StateStore
// Logs, when not nil, also receives the log output as JSON lines. Writes
// are serialized; read it only after Sync returns.
Logs io.Writer
}
SyncConfig holds the optional settings of Sync.