Skip to content

Latest commit

 

History

History
404 lines (275 loc) · 7.24 KB

File metadata and controls

404 lines (275 loc) · 7.24 KB

nanocal Integration Tests

Run these tests manually using the built binary. Each test describes what to run, what to check, and when to ask the user for help.

Use nanocal from ~/bin/nanocal (the installed release build).

Setup

Before starting, verify the binary is installed and working:

nanocal help

Expect: usage text listing all commands (calendars, events, today, upcoming, show, create, update, delete, help) and global options (--json).


1. Calendars

1a. Default text output

nanocal calendars

Check:

  • Columnar output: CALENDAR, TYPE, WRITABLE
  • At least one calendar listed
  • Types are recognizable (local, calDAV, subscription, birthday, etc.)
  • Writable is "yes" or "no"
  • No raw JSON

1b. JSON output

nanocal calendars --json

Check:

  • Valid JSON array
  • Each object has: identifier (string), title (string), type (string), writable (boolean), color (string starting with #)

2. Today

2a. Default text output

nanocal today

Check:

  • Shows today's events grouped under a date header (e.g., "Today, Wednesday, Mar 4, 2026")
  • Each event shows time range (HH:MM – HH:MM), title, and [Calendar]
  • All-day events show "(all day)" instead of time range
  • No event IDs shown by default
  • If no events: "No events found."
  • No raw JSON

2d. IDs flag

nanocal today --ids

Check:

  • Same output as 2a but each event has an indented "ID: " line below it
  • IDs are UUID strings

Without --ids:

nanocal today

Check:

  • No ID lines shown

2b. JSON output

nanocal today --json

Check:

  • Valid JSON array
  • Each object has: id, title, startDate, endDate, isAllDay, calendar
  • Dates are ISO 8601 strings with fractional seconds

2c. Calendar filter

Pick a calendar name from the calendars output.

nanocal today -c "<CalendarName>"

Check:

  • Only events from that calendar are shown
  • Events from other calendars are excluded

3. Upcoming

3a. Default text output

nanocal upcoming

Check:

  • Shows events for the next 7 days
  • Events grouped by day with date headers
  • Multiple days visible (if events exist across days)

3b. Custom days

nanocal upcoming --days 14

Check:

  • Shows events up to 14 days out
  • May include more events than the 7-day default

3c. Search filter

nanocal upcoming --search "meeting" --days 30

Check:

  • Only events matching "meeting" in title, location, notes, or attendees
  • If no matches: "No events found."

3d. Pagination

nanocal upcoming --limit 2
nanocal upcoming --limit 2 --offset 2

Check:

  • First command returns at most 2 events
  • Second command returns different events (no overlap)
  • If fewer than 4 upcoming events, ask the user to create a few test events

4. Events

4a. Date range

nanocal events --from "2026-01-01" --to "2026-03-01"

Check:

  • Shows events in the specified range
  • Events grouped by day
  • No events outside the date range

4b. Default (today only)

nanocal events

Check:

  • Same results as nanocal today

4c. JSON output

nanocal events --from "2026-01-01" --to "2026-03-01" --json

Check:

  • Valid JSON array of event summaries
  • All dates within the specified range

4d. Calendar filter + search

nanocal events --from "2026-01-01" --to "2026-12-31" -c "<CalendarName>" --search "test"

Check:

  • Only events from the specified calendar matching "test"

5. Show

5a. Show event details

Pick an event ID from any of the above commands (use --ids or --json to get the id field).

nanocal show --id "<EVENT-ID>"

Check:

  • Shows full event details: title, when, calendar, location, status, availability
  • Shows attendees if present (name, email, status, role)
  • Shows notes, URL, organizer, recurrence if present
  • Shows event ID at the bottom

5b. JSON output

nanocal show --id "<EVENT-ID>" --json

Check:

  • Valid JSON object
  • Has all fields: id, title, startDate, endDate, isAllDay, calendar, status, availability
  • Optional fields present when applicable: location, notes, url, attendees, organizer, recurrence

5c. Invalid ID

nanocal show --id "nonexistent-id-12345" 2>&1

Check:

  • Error on stderr: "nanocal: event not found: nonexistent-id-12345"
  • Non-zero exit code

6. Create (skip unless user approves)

Only run these if the user explicitly approves creating test events.

6a. Missing required args

nanocal create 2>&1
nanocal create -c "Work" 2>&1
nanocal create -c "Work" --title "Test" 2>&1

Check:

  • First errors about missing -c
  • Second errors about missing --title
  • Third errors about missing --start

6b. Create event (if approved)

Ask the user for a writable calendar name.

nanocal create -c "<Calendar>" --title "nanocal test event" --start "2026-12-25T10:00:00" --end "2026-12-25T11:00:00" --location "Test Location" --notes "Created by nanocal test"

Check:

  • Output: "Created: nanocal test event" with date and calendar info
  • Save the event ID for update/delete tests

6c. JSON create

nanocal create -c "<Calendar>" --title "nanocal JSON test" --start "2026-12-26T10:00:00" --end "2026-12-26T11:00:00" --json

Check:

  • Valid JSON with event summary fields

7. Update (skip unless create test ran)

7a. Update event

Use the event ID from the create test.

nanocal update --id "<EVENT-ID>" --title "nanocal UPDATED test event" --location "New Location"

Check:

  • Output: "Updated: nanocal UPDATED test event" with date and calendar
  • Title and location reflect the changes

7b. Missing ID

nanocal update --title "test" 2>&1

Check:

  • Error: "nanocal: update requires --id"

8. Delete (skip unless create test ran)

8a. Delete event

Use the event IDs from the create tests.

nanocal delete --id "<EVENT-ID>"

Check:

  • Output: "Deleted: "

8b. Verify deletion

nanocal show --id "<EVENT-ID>" 2>&1

Check:

  • Error: "nanocal: event not found: "

8c. Missing ID

nanocal delete 2>&1

Check:

  • Error: "nanocal: delete requires --id"

9. Help

9a. Global help

nanocal help

Check:

  • Lists all commands
  • Shows --json as a global option

9b. Per-command help

nanocal help events
nanocal help create
nanocal help show

Check:

  • Each shows usage, description, and options
  • events mentions --from, --to, -c, --search, --limit, --offset
  • create mentions -c, --title, --start, --end, --allday, --location, --notes, --url
  • show mentions --id

9c. Help aliases

nanocal --help
nanocal -h

Check:

  • Both show the same global help as nanocal help

10. Edge cases

10a. No arguments

nanocal

Check:

  • Shows usage help (same as nanocal help)

10b. Unknown command

nanocal foobar 2>&1

Check:

  • Error on stderr: "nanocal: unknown command: foobar"
  • Exit code is non-zero

10c. Read-only calendar

Try to create an event in a read-only calendar (e.g., "Birthdays" or a subscription calendar):

nanocal create -c "Birthdays" --title "Test" --start "2026-12-25T10:00:00" --end "2026-12-25T11:00:00" 2>&1

Check:

  • Error about calendar being read-only
  • No event created