community/mock-preset-google-calendar

Google Calendar preset for aux4/mock.

One command replaces the Google Calendar API with a local mock: the calendar list, the events collection and item (GET/POST/PATCH/DELETE), quickAdd, and freeBusy. Point a Google Calendar client at the mock with --apiUrl and it behaves like the real service, offline.

Installation

aux4 aux4 pkger install community/mock-preset-google-calendar

Installing pulls in community/mock-preset-google-auth, which supplies the credentials every Google API call needs.

Usage

Start a mock, apply the credentials, then apply the calendar endpoints:

aux4 mock start --port 18901
aux4 mock preset google auth --port 18901
aux4 mock preset google calendar --port 18901

auth writes google-token.json and stubs the OAuth endpoints; calendar stubs the API. A Calendar client then runs entirely against the mock:

aux4 google calendar events list --tokenFile google-token.json --apiUrl http://127.0.0.1:18901/api
{"kind":"calendar#events","summary":"Sally","items":[{"kind":"calendar#event","id":"evt1","status":"confirmed","summary":"Team sync","start":{"dateTime":"2026-01-15T09:00:00Z"},"end":{"dateTime":"2026-01-15T10:00:00Z"}}]}

Endpoints

| Method | Path | Returns | |---|---|---| | GET | /users/me/calendarList | one calendar, from --calendar | | GET | /calendars/{calendarId}/events | a one-event list | | POST | /calendars/{calendarId}/events | the created event | | POST | /calendars/{calendarId}/events/quickAdd | the created event | | GET | /calendars/{calendarId}/events/{eventId} | the event | | PATCH | /calendars/{calendarId}/events/{eventId} | the updated event | | DELETE | /calendars/{calendarId}/events/{eventId} | 204, no body | | POST | /freeBusy | one busy block, from --start/--end |

The paths are templates: any calendar id and any event id match, whatever --calendarId and --eventId are set to. Those flags control what the bodies say.

Shaping the responses

Name the calendar, the event, and its times:

aux4 mock preset google calendar --port 18901 \
  --calendar "Work" --event "Design review" \
  --start 2026-03-01T14:00:00Z --end 2026-03-01T15:00:00Z

| Option | Description | Default | |---|---|---| | --port | Port of the running mock server | 7070 | | --name | Stable handle of the server, instead of --port | | | --stateDir | Explicit state directory | | | --calendar | Calendar display name | Sally | | --calendarId | Calendar id in the response bodies | primary | | --event | Event title | Team sync | | --eventId | Event id | evt1 | | --start | Event start, RFC3339 | 2026-01-15T09:00:00Z | | --end | Event end, RFC3339 | 2026-01-15T10:00:00Z |

For a response the flags do not reach, replace a whole body: --calendarListBody, --eventBody, --eventsBody, and --freeBusyBody each take raw JSON. Use --eventsBody to return several events, or an empty items array to test the no-results path.

Layering your own stubs

A preset is a starting point, not a wall. Apply it, then override any single endpoint with aux4 mock stub — the later stub wins:

aux4 mock preset google calendar --port 18901
aux4 mock stub --port 18901 --method GET --path '/calendars/{calendarId}/events' --status 403 \
  --body '{"error":{"code":403,"message":"Rate Limit Exceeded","status":"PERMISSION_DENIED"}}'

That is how to test an error path: take the whole API from the preset and bend the one endpoint under test.

See also

  • community/mock-preset-google-auth — the credentials every Google preset needs
  • aux4/mock — the mock server itself