Skip to main content
Glama
box-create.exp16.9 kB
#!/usr/bin/env expect # NOTE: This test file excludes env and label related tests as they are for internal use only # The following test cases are commented out or removed: # - Test 4: Linux box create with environment variables (--env) # - Test 5: Linux box create with labels (--label) # - Test 10: Android box create with all options (contains --label) # 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 box create command...${NC}" # Test 1: Basic box create command without type (should show error) puts "\n${YELLOW}Testing basic box create command without type...${NC}" puts "${BLUE}Running Test 1: Basic box create command without type${NC}" if {[catch { spawn $gbox_binary box create expect { -re "please specify a box type: linux or android" { puts "${GREEN}✓ Found expected error message for missing type${NC}" exp_continue } timeout { puts "${RED}✗ Timeout waiting for error message${NC}" exit 1 } eof { puts "${GREEN}✓ Error message displayed correctly${NC}" } } catch {close} } result]} { puts "${RED}✗ Test failed: $result${NC}" exit 1 } # Test 2: Help command for box create puts "\n${YELLOW}Testing help command for box create...${NC}" puts "${BLUE}Running Test 2: Help command for box create${NC}" if {[catch { spawn $gbox_binary box create --help expect { -re "Create a new box" { 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 } } expect { -re "Available box types:" { puts "${GREEN}✓ Found available box types section${NC}" } timeout { puts "${RED}✗ Timeout waiting for available box types${NC}" exit 1 } } expect { -re "linux.*Create a Linux container box" { puts "${GREEN}✓ Found Linux box type description${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux description${NC}" exit 1 } } expect { -re "android.*Create an Android device box" { puts "${GREEN}✓ Found Android box type description${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android description${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Help command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for help completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Help test failed: $result${NC}" exit 1 } # Test 3: Linux box create command puts "\n${YELLOW}Testing Linux box create command...${NC}" puts "${BLUE}Running Test 3: Linux box create command${NC}" if {[catch { spawn $gbox_binary box create linux expect { -re "Linux box created with ID" { puts "${GREEN}✓ Linux box created successfully${NC}" } -re "Linux box created successfully" { puts "${GREEN}✓ Linux box created successfully (no ID)${NC}" } -re "failed to create Linux box" { puts "${GREEN}✓ Expected error for Linux box creation (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux box creation${NC}" exit 1 } eof { puts "${RED}✗ Linux create command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Linux box create command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux command completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Linux box create test failed: $result${NC}" exit 1 } # Test 4: Linux box create with environment variables (removed - internal use only) # Test 5: Linux box create with labels (removed - internal use only) # Test 4: Linux box create with JSON output puts "\n${YELLOW}Testing Linux box create with JSON output...${NC}" puts "${BLUE}Running Test 4: Linux box create with JSON output${NC}" if {[catch { spawn $gbox_binary box create linux --output json expect { -re "\{" { puts "${GREEN}✓ Found JSON opening brace${NC}" } -re "failed to create Linux box" { puts "${GREEN}✓ Expected error for Linux box creation JSON (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for JSON output${NC}" exit 1 } eof { puts "${RED}✗ Linux create JSON command exited unexpectedly${NC}" exit 1 } } expect { -re "\"id\":" { puts "${GREEN}✓ Found id field in JSON${NC}" } -re "\"type\":" { puts "${GREEN}✓ Found type field in JSON${NC}" } -re "failed to create Linux box" { puts "${GREEN}✓ Expected error for Linux box creation JSON (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for JSON fields${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Linux box create JSON command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux JSON completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Linux box create JSON test failed: $result${NC}" exit 1 } # Test 5: Android box create command puts "\n${YELLOW}Testing Android box create command...${NC}" puts "${BLUE}Running Test 5: Android box create command${NC}" if {[catch { spawn $gbox_binary box create android expect { -re "Android box created with ID" { puts "${GREEN}✓ Android box created successfully${NC}" } -re "Android box created successfully" { puts "${GREEN}✓ Android box created successfully (no ID)${NC}" } -re "failed to create Android box" { puts "${GREEN}✓ Expected error for Android box creation (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android box creation${NC}" exit 1 } eof { puts "${RED}✗ Android create command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Android box create command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android command completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Android box create test failed: $result${NC}" exit 1 } # Test 6: Android box create with virtual device type puts "\n${YELLOW}Testing Android box create with virtual device type...${NC}" puts "${BLUE}Running Test 6: Android box create with virtual device type${NC}" if {[catch { spawn $gbox_binary box create android --device-type virtual expect { -re "Android box created with ID" { puts "${GREEN}✓ Android box created with virtual device successfully${NC}" } -re "Android box created successfully" { puts "${GREEN}✓ Android box created with virtual device successfully (no ID)${NC}" } -re "failed to create Android box" { puts "${GREEN}✓ Expected error for Android box creation with device type (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android box creation with device type${NC}" exit 1 } eof { puts "${RED}✗ Android create with device type command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Android box create with device type command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android with device type completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Android box create with device type test failed: $result${NC}" exit 1 } # Test 7: Android box create with physical device type puts "\n${YELLOW}Testing Android box create with physical device type...${NC}" puts "${BLUE}Running Test 7: Android box create with physical device type${NC}" if {[catch { spawn $gbox_binary box create android --device-type physical expect { -re "Android box created with ID" { puts "${GREEN}✓ Android box created with physical device successfully${NC}" } -re "Android box created successfully" { puts "${GREEN}✓ Android box created with physical device successfully (no ID)${NC}" } -re "failed to create Android box" { puts "${GREEN}✓ Expected error for Android box creation with physical device type (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android box creation with physical device type${NC}" exit 1 } eof { puts "${RED}✗ Android create with physical device type command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Android box create with physical device type command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android with physical device type completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Android box create with physical device type test failed: $result${NC}" exit 1 } # Test 8: Android box create with expiration time puts "\n${YELLOW}Testing Android box create with expiration time...${NC}" puts "${BLUE}Running Test 8: Android box create with expiration time${NC}" if {[catch { spawn $gbox_binary box create android --expires-in 30m expect { -re "Android box created with ID" { puts "${GREEN}✓ Android box created with expiration time successfully${NC}" } -re "Android box created successfully" { puts "${GREEN}✓ Android box created with expiration time successfully (no ID)${NC}" } -re "failed to create Android box" { puts "${GREEN}✓ Expected error for Android box creation with expiration (API not available)${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android box creation with expiration${NC}" exit 1 } eof { puts "${RED}✗ Android create with expiration command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Android box create with expiration command completed${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android with expiration completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Android box create with expiration test failed: $result${NC}" exit 1 } # Test 10: Android box create with all options (removed - contains label, internal use only) # Test 9: Invalid device type for Android puts "\n${YELLOW}Testing invalid device type for Android...${NC}" puts "${BLUE}Running Test 9: Invalid device type for Android${NC}" if {[catch { spawn $gbox_binary box create android --device-type invalid expect { -re "invalid device type: invalid" { puts "${GREEN}✓ Found expected error for invalid device type${NC}" } timeout { puts "${RED}✗ Timeout waiting for invalid device type error${NC}" exit 1 } eof { puts "${RED}✗ Invalid device type command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Invalid device type error displayed correctly${NC}" } timeout { puts "${RED}✗ Timeout waiting for invalid device type completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Invalid device type test failed: $result${NC}" exit 1 } # Test 10: Invalid expiration time format puts "\n${YELLOW}Testing invalid expiration time format...${NC}" puts "${BLUE}Running Test 10: Invalid expiration time format${NC}" if {[catch { spawn $gbox_binary box create android --expires-in invalid expect { -re "invalid expires-in format: invalid" { puts "${GREEN}✓ Found expected error for invalid expiration format${NC}" } timeout { puts "${RED}✗ Timeout waiting for invalid expiration format error${NC}" exit 1 } eof { puts "${RED}✗ Invalid expiration format command exited unexpectedly${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Invalid expiration format error displayed correctly${NC}" } timeout { puts "${RED}✗ Timeout waiting for invalid expiration format completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Invalid expiration format test failed: $result${NC}" exit 1 } # Test 11: Linux box create help puts "\n${YELLOW}Testing Linux box create help...${NC}" puts "${BLUE}Running Test 11: Linux box create help${NC}" if {[catch { spawn $gbox_binary box create linux --help expect { -re "Create a new Linux box" { puts "${GREEN}✓ Found Linux help description${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux help description${NC}" exit 1 } eof { puts "${RED}✗ Linux help command exited unexpectedly${NC}" exit 1 } } expect { -re "Flags:" { puts "${GREEN}✓ Found Flags section in Linux help${NC}" } -re "Usage:" { puts "${GREEN}✓ Found Usage section in Linux help${NC}" } timeout { puts "${RED}✗ Timeout waiting for Flags or Usage section${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Linux help command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for Linux help completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Linux help test failed: $result${NC}" exit 1 } # Test 12: Android box create help puts "\n${YELLOW}Testing Android box create help...${NC}" puts "${BLUE}Running Test 12: Android box create help${NC}" if {[catch { spawn $gbox_binary box create android --help expect { -re "Create a new Android box" { puts "${GREEN}✓ Found Android help description${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android help description${NC}" exit 1 } eof { puts "${RED}✗ Android help command exited unexpectedly${NC}" exit 1 } } expect { -re "Flags:" { puts "${GREEN}✓ Found Flags section in Android help${NC}" } -re "Usage:" { puts "${GREEN}✓ Found Usage section in Android help${NC}" } timeout { puts "${RED}✗ Timeout waiting for Flags or Usage section${NC}" exit 1 } } expect { eof { puts "${GREEN}✓ Android help command completed successfully${NC}" } timeout { puts "${RED}✗ Timeout waiting for Android help completion${NC}" exit 1 } } catch {close} } result]} { puts "${RED}✗ Android help test failed: $result${NC}" exit 1 } puts "\n${GREEN}All box create 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