Skip to main content

Module mock

Module mock 

Source
Expand description

Mock opencode binary logic (Task 12). tests/bin/mock_opencode.rs is a shim over main.

Test infrastructure only: it reads keyed fixtures from MOCK_OPENCODE_FIXTURES, keeps counters and an argv log in MOCK_OPENCODE_STATE_DIR, and never touches the real home, the network or a real opencode.

StructsΒ§

Ctx πŸ”’
Reply πŸ”’

EnumsΒ§

Outcome πŸ”’

ConstantsΒ§

DEFAULT_BIG πŸ”’
DEFAULT_URL πŸ”’
PIPE_CAP πŸ”’
UNREACHABLE_STDERR
The captured real stderr of opencode api server.info --server http://127.0.0.1:1 (opencode v2.0.32; the raised error is server-connection.ts:96).

FunctionsΒ§

append_log πŸ”’
big_array πŸ”’
count_poll πŸ”’
Count one poll of key (append one byte; the file length is the count).
env_presence_line
One argv-log line (no trailing newline): {argv, env:{<name>:{present,len,sha8}}, stdout_kind} for OPENCODE_PASSWORD, OPENCODE_SERVER_PASSWORD and every OPENCODE_CTL_*; never a value.
expand_now πŸ”’
Expand whole-string "{{now}}", "{{now-N}}", "{{now+N}}" to numbers.
finish πŸ”’
fixture_key
<op>__<k>=<v>&...: pairs sorted by name, values (not names) percent-encoded. With no params the key is the bare operation id.
is_stdout_pipe
Whether fd 1 is a pipe (the mock truncates big output only then).
main
next_seq πŸ”’
Claim the next 1-based sequence number for key: the first free <key>.<n>.seen marker.
now_ms πŸ”’
parse_api πŸ”’
Parse api arguments after the subcommand: the first positional(s), --param k=v, -d <json>, --server <url>.
parse_mode
MOCK_OPENCODE_MODE = <key>:<mode>[,...].
pending_row πŸ”’
A non-empty permission or form list row for the polling modes.
percent_encode
Percent-encode every byte outside [A-Za-z0-9_.-] as uppercase %XX.
reply_from_fixture πŸ”’
select_fixture
Pick the fixture file under <fixtures>/mock/, most specific first: <op>__<params>__<n>, <op>__<params>, <op>__<n>, <op>. A numbered family past its last file repeats that last file.
spawn_grandchild πŸ”’
tagged πŸ”’
unknown_error_stack πŸ”’
validate_body
The first required property of the operation’s JSON body that body lacks.
write_stdout πŸ”’