Skip to main content
Glama
profile-list.exp10.8 kB
#!/usr/bin/env expect # Exit codes: # 0 - Test passed # 1 - Test failed # Set timeout for command execution set timeout 30 # Colors for output set GREEN "\033\[0;32m" set RED "\033\[0;31m" set YELLOW "\033\[1;33m" set BLUE "\033\[0;34m" set NC "\033\[0m" # Get the gbox binary path # Default to using the built binary in the parent directory set gbox_binary "../gbox" # If the built binary doesn't exist, fall back to system gbox if {![file exists $gbox_binary]} { set gbox_binary "gbox" } puts "${BLUE}Testing gbox profile list command...${NC}" # Test 1: Basic profile list command puts "\n${YELLOW}Testing basic profile list command...${NC}" if {[catch { spawn $gbox_binary profile list expect { -re "ID.*Key.*Organization" { puts "${GREEN}✓ Found table header${NC}" } -re "No profiles found" { puts "${GREEN}✓ Found 'No profiles found' message${NC}" } timeout { puts "${RED}✗ Timeout waiting for table header or 'No profiles found'${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Basic profile list command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for command completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Test failed: $result${NC}" exit 1 } # Test 2: JSON output format puts "\n${YELLOW}Testing JSON output format...${NC}" if {[catch { spawn $gbox_binary profile list --format json expect { -re "\\\[" { puts "${GREEN}✓ Found JSON array opening bracket${NC}" } -re "\\\]" { puts "${GREEN}✓ Found JSON array closing bracket${NC}" } timeout { puts "${RED}✗ Timeout waiting for JSON output${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ JSON profile list command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for JSON command completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ JSON profile list test failed: $result${NC}" exit 1 } # Test 3: Short format flag (-f json) puts "\n${YELLOW}Testing short format flag (-f json)...${NC}" if {[catch { spawn $gbox_binary profile list -f json expect { -re "\\\[" { puts "${GREEN}✓ Found JSON array opening bracket with short flag${NC}" } -re "\\\]" { puts "${GREEN}✓ Found JSON array closing bracket with short flag${NC}" } timeout { puts "${RED}✗ Timeout waiting for JSON output with short flag${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Short JSON format command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for short JSON completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Short JSON format test failed: $result${NC}" exit 1 } # Test 4: Table format (default) puts "\n${YELLOW}Testing table format (default)...${NC}" if {[catch { spawn $gbox_binary profile list --format table expect { -re "ID.*Key.*Organization" { puts "${GREEN}✓ Found table header with explicit table format${NC}" } -re "No profiles found" { puts "${GREEN}✓ Found 'No profiles found' with explicit table format${NC}" } timeout { puts "${RED}✗ Timeout waiting for table format output${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Table format command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for table format completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Table format test failed: $result${NC}" exit 1 } # Test 5: Short table format flag (-f table) puts "\n${YELLOW}Testing short table format flag (-f table)...${NC}" if {[catch { spawn $gbox_binary profile list -f table expect { -re "ID.*Key.*Organization" { puts "${GREEN}✓ Found table header with short table format flag${NC}" } -re "No profiles found" { puts "${GREEN}✓ Found 'No profiles found' with short table format flag${NC}" } timeout { puts "${RED}✗ Timeout waiting for short table format output${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Short table format command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for short table format completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Short table format test failed: $result${NC}" exit 1 } # Test 6: Invalid format option puts "\n${YELLOW}Testing invalid format option...${NC}" if {[catch { spawn $gbox_binary profile list --format invalid expect { -re "Error:" { puts "${GREEN}✓ Found expected error for invalid format${NC}" } -re "invalid format" { puts "${GREEN}✓ Found expected invalid format error${NC}" } -re "unsupported format" { puts "${GREEN}✓ Found expected unsupported format error${NC}" } eof { puts "${GREEN}✓ Invalid format error displayed correctly${NC}" } timeout { puts "${RED}✗ Timeout waiting for invalid format error${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Invalid format test failed: $result${NC}" exit 1 } # Test 7: Help command puts "\n${YELLOW}Testing help command...${NC}" if {[catch { spawn $gbox_binary profile list --help expect { -re "List all profiles" { puts "${GREEN}✓ Found help description${NC}" } timeout { puts "${RED}✗ Timeout waiting for help description${NC}" exit 1 } eof { puts "${RED}✗ Help command exited unexpectedly${NC}" exit 1 } } # Look for flags section in the output expect { -re "Flags:" { puts "${GREEN}✓ Found Flags section${NC}" } timeout { puts "${RED}✗ Timeout waiting for Flags section${NC}" exit 1 } } expect { -re "-f, --format.*Output format" { puts "${GREEN}✓ Found format flag description${NC}" } eof { puts "${GREEN}✓ Help command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for flag descriptions${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Help test failed: $result${NC}" exit 1 } # Test 8: Profile command help puts "\n${YELLOW}Testing profile command help...${NC}" if {[catch { spawn $gbox_binary profile --help set description_found 0 set commands_found 0 set list_found 0 expect { -re "Manage configuration information" { puts "${GREEN}✓ Found profile command description${NC}" set description_found 1 exp_continue } -re "Available Commands:" { puts "${GREEN}✓ Found Available Commands section${NC}" set commands_found 1 exp_continue } -re "list.*List all profiles" { puts "${GREEN}✓ Found list command in help output${NC}" set list_found 1 exp_continue } eof { puts "${GREEN}✓ Profile help command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for profile help output${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Profile help test failed: $result${NC}" exit 1 } # Test 9: Test with extra arguments (should show error) puts "\n${YELLOW}Testing with extra arguments...${NC}" if {[catch { spawn $gbox_binary profile list extra-arg expect { -re "Error:" { puts "${GREEN}✓ Found expected error for extra arguments${NC}" } -re "unknown command" { puts "${GREEN}✓ Found expected unknown command error${NC}" } -re "too many arguments" { puts "${GREEN}✓ Found expected too many arguments error${NC}" } eof { puts "${GREEN}✓ Extra arguments error displayed correctly${NC}" } timeout { puts "${RED}✗ Timeout waiting for extra arguments error${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Extra arguments test failed: $result${NC}" exit 1 } # Test 10: Test profile list with no profiles (empty state) puts "\n${YELLOW}Testing profile list with no profiles (empty state)...${NC}" if {[catch { spawn $gbox_binary profile list expect { -re "No profiles found" { puts "${GREEN}✓ Found 'No profiles found' message in empty state${NC}" } -re "ID.*Key.*Organization" { puts "${GREEN}✓ Found table header even in empty state${NC}" } timeout { puts "${RED}✗ Timeout waiting for empty state output${NC}" exit 1 } eof { puts "${RED}✗ Command exited unexpectedly in empty state${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Empty state command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for empty state completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Empty state test failed: $result${NC}" exit 1 } puts "\n${GREEN}All profile list tests passed successfully!${NC}" exit 0

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/babelcloud/gru-sandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server