@@ -130,4 +130,100 @@ func TestClient(t *testing.T) {
130130 t .Errorf ("Expected state to be 'disconnected', got %q" , client .GetState ())
131131 }
132132 })
133+
134+ t .Run ("should get status with version and protocol info" , func (t * testing.T ) {
135+ client := copilot .NewClient (& copilot.ClientOptions {
136+ CLIPath : cliPath ,
137+ UseStdio : true ,
138+ })
139+ t .Cleanup (func () { client .ForceStop () })
140+
141+ if err := client .Start (); err != nil {
142+ t .Fatalf ("Failed to start client: %v" , err )
143+ }
144+
145+ status , err := client .GetStatus ()
146+ if err != nil {
147+ t .Fatalf ("Failed to get status: %v" , err )
148+ }
149+
150+ if status .Version == "" {
151+ t .Error ("Expected status.Version to be non-empty" )
152+ }
153+
154+ if status .ProtocolVersion < 1 {
155+ t .Errorf ("Expected status.ProtocolVersion >= 1, got %d" , status .ProtocolVersion )
156+ }
157+
158+ client .Stop ()
159+ })
160+
161+ t .Run ("should get auth status" , func (t * testing.T ) {
162+ client := copilot .NewClient (& copilot.ClientOptions {
163+ CLIPath : cliPath ,
164+ UseStdio : true ,
165+ })
166+ t .Cleanup (func () { client .ForceStop () })
167+
168+ if err := client .Start (); err != nil {
169+ t .Fatalf ("Failed to start client: %v" , err )
170+ }
171+
172+ authStatus , err := client .GetAuthStatus ()
173+ if err != nil {
174+ t .Fatalf ("Failed to get auth status: %v" , err )
175+ }
176+
177+ // isAuthenticated is a bool, just verify we got a response
178+ if authStatus .IsAuthenticated {
179+ if authStatus .AuthType == nil {
180+ t .Error ("Expected authType to be set when authenticated" )
181+ }
182+ if authStatus .StatusMessage == nil {
183+ t .Error ("Expected statusMessage to be set when authenticated" )
184+ }
185+ }
186+
187+ client .Stop ()
188+ })
189+
190+ t .Run ("should list models when authenticated" , func (t * testing.T ) {
191+ client := copilot .NewClient (& copilot.ClientOptions {
192+ CLIPath : cliPath ,
193+ UseStdio : true ,
194+ })
195+ t .Cleanup (func () { client .ForceStop () })
196+
197+ if err := client .Start (); err != nil {
198+ t .Fatalf ("Failed to start client: %v" , err )
199+ }
200+
201+ authStatus , err := client .GetAuthStatus ()
202+ if err != nil {
203+ t .Fatalf ("Failed to get auth status: %v" , err )
204+ }
205+
206+ if ! authStatus .IsAuthenticated {
207+ // Skip if not authenticated - models.list requires auth
208+ client .Stop ()
209+ return
210+ }
211+
212+ models , err := client .ListModels ()
213+ if err != nil {
214+ t .Fatalf ("Failed to list models: %v" , err )
215+ }
216+
217+ if len (models ) > 0 {
218+ model := models [0 ]
219+ if model .ID == "" {
220+ t .Error ("Expected model.ID to be non-empty" )
221+ }
222+ if model .Name == "" {
223+ t .Error ("Expected model.Name to be non-empty" )
224+ }
225+ }
226+
227+ client .Stop ()
228+ })
133229}
0 commit comments