@@ -48,6 +48,13 @@ T["Gemini adapter"]["can form messages to be sent to the API"] = function()
4848 h .eq (output , adapter .handlers .form_messages (adapter , messages ))
4949end
5050
51+ T [" Gemini adapter" ][" it can form tools to be sent to the API" ] = function ()
52+ local weather = require (" tests/strategies/chat/agents/tools/stubs/weather" ).schema
53+ local tools = { weather = { weather } }
54+
55+ h .eq ({ tools = { weather } }, adapter .handlers .form_tools (adapter , tools ))
56+ end
57+
5158T [" Gemini adapter" ][" Streaming" ] = new_set ()
5259
5360T [" Gemini adapter" ][" Streaming" ][" can output streamed data into the chat buffer" ] = function ()
@@ -63,6 +70,27 @@ T["Gemini adapter"]["Streaming"]["can output streamed data into the chat buffer"
6370 h .expect_starts_with (" Elegant, dynamic" , output )
6471end
6572
73+ T [" Gemini adapter" ][" Streaming" ][" can process tools" ] = function ()
74+ local tools = {}
75+ local lines = vim .fn .readfile (" tests/adapters/stubs/gemini_tools_streaming.txt" )
76+ for _ , line in ipairs (lines ) do
77+ adapter .handlers .chat_output (adapter , line , tools )
78+ end
79+
80+ local tool_output = {
81+ [" 1" ] = {
82+ arguments = ' {"units":"celsius","location":"London"}' ,
83+ name = " weather" ,
84+ },
85+ [" 2" ] = {
86+ arguments = ' {"units":"celsius","location":"Paris"}' ,
87+ name = " weather" ,
88+ },
89+ }
90+
91+ h .eq (tool_output , tools )
92+ end
93+
6694T [" Gemini adapter" ][" No Streaming" ] = new_set ({
6795 hooks = {
6896 pre_case = function ()
@@ -85,6 +113,35 @@ T["Gemini adapter"]["No Streaming"]["can output for the chat buffer"] = function
85113 h .expect_starts_with (" Elegant, dynamic." , adapter .handlers .chat_output (adapter , json ).output .content )
86114end
87115
116+ T [" Gemini adapter" ][" No Streaming" ][" can process tools" ] = function ()
117+ local data = vim .fn .readfile (" tests/adapters/stubs/gemini_tools_no_streaming.txt" )
118+ data = table.concat (data , " \n " )
119+
120+ local tools = {}
121+
122+ -- Match the format of the actual request
123+ local json = { body = data }
124+ adapter .handlers .chat_output (adapter , json , tools )
125+
126+ local tool_output = {
127+ [" 1" ] = {
128+ arguments = {
129+ location = " London, UK" ,
130+ units = " celsius" ,
131+ },
132+ name = " weather" ,
133+ },
134+ [" 2" ] = {
135+ arguments = {
136+ location = " Paris, France" ,
137+ units = " celsius" ,
138+ },
139+ name = " weather" ,
140+ },
141+ }
142+ h .eq (tool_output , tools )
143+ end
144+
88145T [" Gemini adapter" ][" No Streaming" ][" can output for the inline assistant" ] = function ()
89146 local data = vim .fn .readfile (" tests/adapters/stubs/gemini_no_streaming.txt" )
90147 data = table.concat (data , " \n " )
0 commit comments