Notes on the test suite added during development of glean-code-cli. See Running tests for the user-facing instructions on how to run the tests.
All 740 tests pass. Here's what was added across the development passes:
tests/test_commands_extended.py (155 new tests) — covers all previously untested commands:
/status,/clear,/help/datasources.list(all flag combinations),/datasources.status,/indexing.rotate-token/autocomplete,/recommendations,/feedback,/entities.list/pins.delete,/collections.delete/shortcuts.list,/shortcuts.get,/shortcuts.create,/shortcuts.update,/shortcuts.delete(full flag coverage)/answers.list,/answers.get,/answers.create,/answers.update,/answers.delete(int ID validation, arg passing)/summarize(by URL, by ID, query flag)/verification.list,/verification.verify,/verification.remind(flag passthrough, defaults)/messages.get,/activity.report,/insights(CSV export, all flags)/scaffoldwith--outputflag, cancellation paths_fmt_ts,_render_insights,_export_insights_csv,_print_datasource_status,Session.refresh_client
tests/test_client_extended.py (31 new tests) — covers all new client methods and mock responses:
- Mock responses for all 19 new endpoints (
/unpin,/listshortcuts,/listanswers,/summarize,/insights, etc.) GleanClientmethod bodies: correct paths, partial updates, optional fields, body construction
tests/test_indexing_walk.py (25 new tests) — covers the --path indexing helpers and command flow:
path_to_id,filename_to_title,mime_for_path— slug, title, and extension detectionwalk_files— default include/exclude behaviour,node_modules/.git/.DS_Storefiltering,--max-bytesskip, single-file root, missing-path errors, custom--includeoverridesfile_to_document— Markdown/HTML body shape, view-URL prefix override, unsupported-extension rejection/index.document --path— synthesizes aDocumentDefinition, dry-run skips the API, directory-passed errors, missing-permissions errors, mutex with--from-file, mutex of--publicand--acl-from-file/index.bulk-documents --path— folder walk produces a pagedBulkIndexDocumentsRequest,--includefiltering, dry-run, backward compat with--from-file
tests/test_commands_extended.py and tests/test_client_extended.py (33 new tests) — covers the Custom Metadata API surface:
GleanClientmethodsset_metadata_schema,get_metadata_schema,delete_metadata_schema,attach_metadata,detach_metadata— correct HTTP methods (PUT/GET/DELETE), correct paths under/rest/api/index, body shape, indexing-token requirement_mock_indexing_responsefor/custom-metadata/schema/{group}(schema-shaped GET, ack-style PUT/DELETE) and/document/{docId}/custom-metadata/{group}(ack-style PUT/DELETE)/metadata.set-schema— required--group, mutual exclusion of--from-fileand--keys, inline-key parsing (name:TYPE[:skip]), invalid-type rejection,--dry-runskip, no-token error, file-list-form parsing/metadata.get-schema,/metadata.delete-schema— required--group, no-token error, correct client-method invocation/metadata.attach— required--doc-idand--group, mutual exclusion of--from-fileand--values, inline-value parsing, malformed-value rejection,--dry-runskip, no-token error/metadata.detach— required flags, no-token error, correct client-method invocation
tests/test_mock_corpus.py (35 new tests) — covers the fake corpus behind mock mode:
- Ranking — relevant document first, distinct top hits for distinct queries, match-all ordered by freshness,
--datasourcefiltering, page padding when nothing matches, page-size cap - Snippets and metadata — snippet drawn from the sentence matching the query, author and relative freshness on every result
- Placeholders —
{Q}/{Q+1}/{FY}expansion, next quarter differs from current, no raw placeholders leak into results - Cross-endpoint coherence — a
/searchresult URL resolves through/getdocumentsand/summarizeto the same document,/chatcitations track the question,/getdocumentpermissionsowner is the document author,/peoplereads the roster - Custom corpus files —
mock_corpus_pathandGLEAN_MOCK_CORPUSoverrides (config wins), bare-array form, andCorpusErroron a missing file, invalid JSON, a document with no title, or an empty document list
tests/test_install.py (10 new tests) — covers app-bundle ownership in the installer:
bundle_identifier/owns_bundle— readsCFBundleIdentifierout ofInfo.plist; a missing bundle counts as ours (nothing to clobber), a foreign identifier and an unreadable or binary plist do not- Refusal —
install_macos_appexits rather than writing into a bundle it did not create, leaving that bundle'sInfo.plistbyte-identical and creating noContents/Resources - Legacy cleanup — an old
Glean.appis removed on install when we own it, and left alone when it belongs to another app - Uninstall — removes our own bundle, and never deletes a foreign one (the regression that would have deleted a user's Glean Desktop install)
- The default
APP_DIRis asserted not to beGlean.app
tests/test_mcp.py (9 new tests) — covers mock mode on the MCP server:
_build_client— forces live mode whatevermodethe config file carries (includingauto), and switches to mock only whenGLEAN_MOCKis set; truthy spellings (1,true,yes,on) accepted, everything else ignored- Labelling — all four tools (
search,chat,list_agents,run_agent) prefix their response with the[MOCK MODE]banner when serving fake data, including empty-result responses, and never in live mode - Tool descriptions — every tool docstring names
GLEAN_MOCK, so the warning reaches the agent before it calls anything