Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/0xjeffro/astroclaw
/ functions
Functions
765 in github.com/0xjeffro/astroclaw
⨍
Functions
765
◇
Types & classes
189
Function
TestAnthropicChatStream
ANTHROPIC_API_KEY=sk-ant-xxx go test ./pkg/provider/ -v -run TestAnthropicChatStream
pkg/provider/anthropic_test.go:10
Function
TestAnthropicChatSync
ANTHROPIC_API_KEY=sk-ant-xxx go test ./pkg/provider/ -v -run TestAnthropicChatSync
pkg/provider/anthropic_test.go:43
Function
TestApproval_Approved
TestApproval_Approved verifies that when OnApproval returns true, the tool executes normally and its real result is returned to the model.
pkg/agent/agent_test.go:331
Function
TestApproval_Denied
TestApproval_Denied verifies that when OnApproval returns false, the tool is NOT executed and the model receives a rejection message.
pkg/agent/agent_test.go:273
Function
TestApproval_NilCallback
TestApproval_NilCallback verifies that when OnApproval is nil (not set), tools with NeedsApproval=true are auto-approved. This ensures backwards compa
pkg/agent/agent_test.go:383
Function
TestBearerTokenExtraction
Unit test for the package-private bearerToken helper. Covers the non-obvious cases: empty header, wrong scheme, exact-prefix collision.
pkg/auth/middleware_test.go:219
Function
TestBuildSystemPrompt_AllSectionsPresent
Verifies that all hardcoded sections are present in the prompt.
pkg/agent/prompt_test.go:89
Function
TestBuildSystemPrompt_DefaultIdentity
Verifies that when SOUL is empty, the default identity is used.
pkg/agent/prompt_test.go:9
Function
TestBuildSystemPrompt_MemoryContextFencing
Verifies that memories are wrapped in context fencing tags.
pkg/agent/prompt_test.go:49
Function
TestBuildSystemPrompt_NoMemories
Verifies that when memories are empty, no memory section appears.
pkg/agent/prompt_test.go:67
Function
TestBuildSystemPrompt_NoUserProfile
Verifies that when USER is empty, no User Profile section appears.
pkg/agent/prompt_test.go:41
Function
TestBuildSystemPrompt_SoulOverridesIdentity
Verifies that when SOUL is provided, it replaces the default identity.
pkg/agent/prompt_test.go:17
Function
TestBuildSystemPrompt_Truncation
Verifies that content exceeding character limits is truncated.
pkg/agent/prompt_test.go:75
Function
TestBuildSystemPrompt_UserProfile
Verifies that USER profile is injected under a "User Profile" heading.
pkg/agent/prompt_test.go:29
Function
TestCanaryDDG
Integration test: actually hits DuckDuckGo. Run with: go test ./pkg/tool/websearch/ -run TestCanaryDDG -v This test validates that the regexes stil
pkg/tool/websearch/ddg_test.go:162
Function
TestCanaryFetch
Integration test: actually fetches a public URL. Run with: go test ./pkg/tool/webfetch/ -run TestCanaryFetch -v Validates that the HTTP client, SSR
pkg/tool/webfetch/webfetch_test.go:215
Function
TestCheckHash
(t *testing.T)
pkg/crypto/password_test.go:180
Function
TestCheckHashBytes
(t *testing.T)
pkg/crypto/password_test.go:198
Function
TestClaimsFromContextMissing
Empty context returns (nil, false), not a panic or zero-Claims pointer.
pkg/auth/middleware_test.go:203
Function
TestComparePasswordAndHash
(t *testing.T)
pkg/crypto/password_test.go:65
Function
TestComparePasswordAndHashBytes
(t *testing.T)
pkg/crypto/password_test.go:92
Function
TestCreateHash
(t *testing.T)
pkg/crypto/password_test.go:10
Function
TestCreateHashBytes
(t *testing.T)
pkg/crypto/password_test.go:35
Function
TestCreateSessionInWorkspace
--- tests -----------------------------------------------------------------
pkg/api/handlers_test.go:168
Function
TestDDGTimeRange
Verify that time range codes map correctly, especially "y" -> "t" (DuckDuckGo's quirk).
pkg/tool/websearch/ddg_test.go:135
Function
TestDecodeHash
(t *testing.T)
pkg/crypto/password_test.go:127
Function
TestDecodeHashBytes
(t *testing.T)
pkg/crypto/password_test.go:160
Function
TestDecryptFailsOnTamperedCiphertext
(t *testing.T)
pkg/crypto/aes_test.go:29
Function
TestDeleteSession
(t *testing.T)
pkg/api/handlers_test.go:247
Function
TestDisconnectCleansRegistry
TestDisconnectCleansRegistry verifies the handler unregisters the conn from the (real DB) Registry when the client closes.
pkg/cloud/wsbus/inprocess/inprocess_test.go:143
Function
TestEachEncryptGeneratesUniqueNonce
(t *testing.T)
pkg/crypto/aes_test.go:41
Function
TestEditFile_AmbiguousMatch
TestEditFile_AmbiguousMatch verifies that old_text appearing more than once is rejected. This forces the model to provide more surrounding context to
pkg/tool/editfile_test.go:91
Function
TestEditFile_BadJSON
TestEditFile_BadJSON verifies that malformed JSON arguments return an error rather than panicking.
pkg/tool/editfile_test.go:143
Function
TestEditFile_DeleteText
TestEditFile_DeleteText verifies that passing an empty new_text effectively deletes old_text from the file. This is the intended way to remove code —
pkg/tool/editfile_test.go:53
Function
TestEditFile_FileNotExist
TestEditFile_FileNotExist verifies that editing a non-existent file returns an error with the file path.
pkg/tool/editfile_test.go:131
Function
TestEditFile_MultilineReplace
TestEditFile_MultilineReplace verifies that old_text and new_text can span multiple lines. This is the common case for real code edits — the model sen
pkg/tool/editfile_test.go:113
Function
TestEditFile_NotFound
TestEditFile_NotFound verifies that old_text not present in the file returns an error. The file must remain unchanged.
pkg/tool/editfile_test.go:69
Function
TestEditFile_SingleReplace
TestEditFile_SingleReplace verifies the happy path: old_text appears exactly once and is replaced with new_text. The rest of the file content must rem
pkg/tool/editfile_test.go:36
Function
TestEncryptDecryptRoundTrip
(t *testing.T)
pkg/crypto/aes_test.go:8
Function
TestEstimateMessageTokens_EmptyMessage
--------------------------------------------------------------------------- Token estimation tests ---------------------------------------------------
pkg/agent/context_test.go:18
Function
TestEstimateMessageTokens_TextOnly
TestEstimateMessageTokens_TextOnly verifies the basic character-to-token formula: tokens = (role + content chars)*2/5 + 12 overhead.
pkg/agent/context_test.go:31
Function
TestEstimateMessageTokens_ToolResult
TestEstimateMessageTokens_ToolResult verifies that a tool result message (role="tool") correctly counts Role, Content, and ToolCallID.
pkg/agent/context_test.go:76
Function
TestEstimateMessageTokens_WithToolCalls
TestEstimateMessageTokens_WithToolCalls verifies that ToolCall metadata (ID, function name, arguments) is included in the token estimate. Without this
pkg/agent/context_test.go:50
Function
TestEstimateTokens_EmptySlice
TestEstimateTokens_EmptySlice verifies that an empty message slice returns 0 tokens.
pkg/agent/context_test.go:107
Function
TestEstimateTokens_MultipleMessages
TestEstimateTokens_MultipleMessages verifies that estimateTokens sums individual message estimates correctly.
pkg/agent/context_test.go:93
Function
TestEstimateToolTokens_Empty
TestEstimateToolTokens_Empty verifies that no tools = 0 tokens.
pkg/agent/context_test.go:139
Function
TestEstimateToolTokens_WithTools
TestEstimateToolTokens_WithTools verifies that tool definition token estimation accounts for name, description, and JSON-serialized parameters. This i
pkg/agent/context_test.go:118
Function
TestEvalArithmetic_BadJSON
TestEvalArithmetic_BadJSON verifies that malformed JSON arguments (i.e. the arguments string from OpenAI is corrupted or not valid JSON) return an err
pkg/tool/arithmetic_test.go:113
Function
TestEvalArithmetic_BasicOps
TestEvalArithmetic_BasicOps verifies that the four basic arithmetic operators produce correct results. These are the most common expressions the model
pkg/tool/arithmetic_test.go:23
Function
TestEvalArithmetic_DivisionByZero
TestEvalArithmetic_DivisionByZero verifies that dividing by zero returns an error rather than panicking or returning Inf. In Go constant evaluation, i
pkg/tool/arithmetic_test.go:128
Function
TestEvalArithmetic_FloatDivision
TestEvalArithmetic_FloatDivision verifies that float division returns an exact rational fraction. types.Eval uses Go's arbitrary-precision constant ar
pkg/tool/arithmetic_test.go:65
Function
TestEvalArithmetic_IntegerDivision
TestEvalArithmetic_IntegerDivision documents Go's integer division semantics: 10/3 truncates to 3, not 3.333 or "10/3". This is standard Go behavior (
pkg/tool/arithmetic_test.go:81
Function
TestEvalArithmetic_InvalidExpression
TestEvalArithmetic_InvalidExpression verifies that a syntactically invalid expression (not valid Go constant syntax) returns an error rather than pani
pkg/tool/arithmetic_test.go:98
Function
TestEvalArithmetic_Parentheses
TestEvalArithmetic_Parentheses verifies that parentheses correctly override operator precedence. Without parentheses, 1+2*3 = 7; with them, (1+2)*3 =
pkg/tool/arithmetic_test.go:50
Function
TestExecCommand_BadJSON
TestExecCommand_BadJSON verifies that malformed JSON arguments return an error rather than panicking.
pkg/tool/exec_test.go:139
Function
TestExecCommand_BasicCommand
TestExecCommand_BasicCommand verifies the happy path: a simple command runs successfully and its stdout is returned.
pkg/tool/exec_test.go:20
Function
TestExecCommand_FailedCommand
TestExecCommand_FailedCommand verifies that a non-zero exit code does NOT cause Run to return an error. Instead, the exit status is appended to the ou
pkg/tool/exec_test.go:50
Function
TestExecCommand_Pipe
TestExecCommand_Pipe verifies that shell features like pipes work, confirming that "sh -c" delegation is functioning correctly. Without "sh -c", the p
pkg/tool/exec_test.go:34
Function
TestExecCommand_Stderr
TestExecCommand_Stderr verifies that stderr output is captured alongside stdout. CombinedOutput merges both streams, so diagnostic messages and error
pkg/tool/exec_test.go:67
Function
TestExecCommand_TruncationByBytes
Verify that output exceeding 50KB is truncated at the byte limit, and that multi-byte UTF-8 characters are not split at the boundary.
pkg/tool/exec_test.go:94
Function
TestExecCommand_TruncationByLines
Verify that output exceeding 2000 lines is truncated at the line limit.
pkg/tool/exec_test.go:78
Function
TestExecCommand_TruncationUTF8Safe
Verify that UTF-8 multi-byte characters are not split when truncating at the byte limit.
pkg/tool/exec_test.go:110
Function
TestExecute_BadScheme
Verify that Execute rejects non-http(s) schemes.
pkg/tool/webfetch/webfetch_test.go:123
Function
TestExecute_BasicSearch
Verify that a basic search passes query, default count, and empty time range to the provider.
pkg/tool/websearch/websearch_test.go:32
Function
TestExecute_CountMax
Verify that count values over 100 are rejected and the default is used instead.
pkg/tool/websearch/websearch_test.go:74
Function
TestExecute_CountOverride
Verify that the model can override the default result count.
pkg/tool/websearch/websearch_test.go:61
Function
TestExecute_CountZero
Verify that count=0 falls back to the default (0 is not a valid count).
pkg/tool/websearch/websearch_test.go:87
Function
TestExecute_DefaultMaxResults
Verify that when MaxResults is not set (zero value), the default of 5 is used.
pkg/tool/websearch/websearch_test.go:203
Function
TestExecute_EmptyQuery
Verify that a whitespace-only query returns an error without calling the provider.
pkg/tool/websearch/websearch_test.go:129
Function
TestExecute_EmptyURL
Verify that Execute rejects empty URL.
pkg/tool/webfetch/webfetch_test.go:136
Function
TestExecute_InvalidJSON
Verify that Execute rejects invalid JSON args.
pkg/tool/webfetch/webfetch_test.go:149
Function
TestExecute_InvalidJSON
Verify that malformed JSON args return an error.
pkg/tool/websearch/websearch_test.go:146
Function
TestExecute_InvalidTimeRange
Verify that an invalid time_range defaults to no filter instead of returning an error.
pkg/tool/websearch/websearch_test.go:113
Function
TestExecute_NoProvider
Verify that calling Execute with no provider configured returns a helpful error.
pkg/tool/websearch/websearch_test.go:159
Function
TestExecute_NoResults
Verify that an empty result set returns a human-readable "no results" message.
pkg/tool/websearch/websearch_test.go:189
Function
TestExecute_ProviderError
Verify that provider errors are surfaced in the tool result.
pkg/tool/websearch/websearch_test.go:172
Function
TestExecute_SSRFBlocked
Verify that Execute blocks private/local URLs (SSRF protection).
pkg/tool/webfetch/webfetch_test.go:95
Function
TestExecute_TimeRange
Verify that a valid time_range is passed through to the provider.
pkg/tool/websearch/websearch_test.go:100
Function
TestExtractDDGURL
Verify that extractDDGURL correctly unwraps DuckDuckGo's redirect URLs and handles direct URLs, missing trailing params, and original URLs with query
pkg/tool/websearch/ddg_test.go:96
Function
TestExtractText
Verify that extractText removes script, style, and noscript blocks, strips tags, and normalizes whitespace into clean readable text.
pkg/tool/webfetch/webfetch_test.go:11
Function
TestExtractText_Empty
Verify that extractText handles empty input without panicking.
pkg/tool/webfetch/webfetch_test.go:41
Function
TestFallbackSummary
TestFallbackSummary verifies the crude fallback: each message is truncated to 10% (min 200 chars) and joined with " | ".
pkg/agent/context_test.go:648
Function
TestFindSafeBoundary_BetweenBoundaries
TestFindSafeBoundary_BetweenBoundaries verifies that when targetIndex falls between two boundaries, the earlier one (at or before target) is returned.
pkg/agent/context_test.go:238
Function
TestFindSafeBoundary_EmptyHistory
TestFindSafeBoundary_EmptyHistory verifies that an empty history returns 0 (no boundaries exist, nothing to cut).
pkg/agent/context_test.go:262
Function
TestFindSafeBoundary_ExactMatch
TestFindSafeBoundary_ExactMatch verifies that when targetIndex falls exactly on a Turn boundary, that boundary is returned.
pkg/agent/context_test.go:222
Function
TestFindSafeBoundary_FallbackToAfter
TestFindSafeBoundary_FallbackToAfter verifies the defensive edge case: if no boundary exists at or before targetIndex (e.g. history starts with non-us
pkg/agent/context_test.go:274
Function
TestForceCompress_AppendToExistingSummary
TestForceCompress_AppendToExistingSummary verifies that if a summary already exists (from a prior summarization), the truncation note is appended rath
pkg/agent/context_test.go:439
Function
TestForceCompress_DropsOldestHalf
--------------------------------------------------------------------------- Force compression tests --------------------------------------------------
pkg/agent/context_test.go:365
Function
TestForceCompress_PreservesToolCallPairs
TestForceCompress_PreservesToolCallPairs verifies that truncation at Turn boundaries keeps tool_call/tool_result pairs intact. If we cut in the middle
pkg/agent/context_test.go:390
Function
TestForceCompress_SetsSummaryNote
TestForceCompress_SetsSummaryNote verifies that forceCompress records how many messages were dropped, so the model knows context was lost.
pkg/agent/context_test.go:417
Function
TestForceCompress_SingleTurn
TestForceCompress_SingleTurn verifies the edge case where history has only one Turn (one user message + many tool calls). cutIndex would be 0, so forc
pkg/agent/context_test.go:479
Function
TestForceCompress_TooShortToCompress
TestForceCompress_TooShortToCompress verifies that history with ≤2 messages is left untouched — cutting it would make things worse.
pkg/agent/context_test.go:461
Function
TestFormatFetchResult
Verify that formatFetchResult includes all metadata fields.
pkg/tool/webfetch/webfetch_test.go:199
Function
TestFormatJSON
Verify that formatJSON pretty-prints valid JSON.
pkg/tool/webfetch/webfetch_test.go:49
Function
TestFormatJSON_Invalid
Verify that formatJSON returns the original string for invalid JSON.
pkg/tool/webfetch/webfetch_test.go:62
Function
TestFormatResults
Verify that formatResults includes query, titles, URLs, and snippets in the output.
pkg/tool/websearch/websearch_test.go:216
Function
TestGetAdmin
(t *testing.T)
pkg/api/handlers_test.go:299
Function
TestGetAdminAuthenticated
After a successful login the stored token is attached to subsequent calls; the protected endpoint returns 200 with the decoded user.
pkg/client/client_test.go:103
Function
TestGetAdminWithoutToken
Without a token a protected call surfaces as ErrUnauthorized so the CLI can prompt for re-login.
pkg/client/client_test.go:124
Function
TestGetCurrentTime_ReturnsValidRFC3339
TestGetCurrentTime_ReturnsValidRFC3339 verifies that the tool returns a string that can be parsed back as RFC 3339. We don't assert the exact time (th
pkg/tool/time_test.go:15
← previous
next →
501–600 of 765, ranked by callers