Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ jobs:

# Test help shows new commands
echo "Testing: help shows stop/start commands"
$BINARY_PATH --help | grep -q "stop" && echo "✅ stop command documented" || echo "❌ stop command missing"
$BINARY_PATH --help | grep -q "start" && echo "✅ start command documented" || echo "❌ start command missing"
$BINARY_PATH breeder --help | grep -q "stop" && echo "✅ stop command documented" || echo "❌ stop command missing"
$BINARY_PATH breeder --help | grep -q "start" && echo "✅ start command documented" || echo "❌ start command missing"
echo "Testing: breeder purge --help shows --force flag"
$BINARY_PATH breeder purge --help | grep -q "force" && echo "✅ --force flag documented in purge" || echo "❌ --force flag missing from purge"

Expand Down Expand Up @@ -321,6 +321,54 @@ jobs:
$BINARY_PATH --hostname=localhost --port=4010 --debug breeder list
echo "✅ --debug flag works"

# === Error Handling Tests ===
echo ""
echo "=== Testing Error Handling ==="

# Test missing file
echo "Testing: missing file error"
if $BINARY_PATH --hostname=localhost --port=4010 breeder create --name=test --file=nonexistent.yml 2>/dev/null; then
echo "❌ Should have failed on missing file"
exit 1
else
echo "✅ Failed on missing file as expected"
fi

# Test missing required argument
echo "Testing: missing --id argument"
if $BINARY_PATH --hostname=localhost --port=4010 breeder show 2>/dev/null; then
echo "❌ Should have failed on missing --id"
exit 1
else
echo "✅ Failed on missing --id as expected"
fi

# === Output Format Tests ===
echo ""
echo "=== Testing Output Formats ==="

echo "Testing: JSON output format"
JSON_OUTPUT=$($BINARY_PATH --hostname=localhost --port=4010 --output=json breeder list)
if echo "$JSON_OUTPUT" | grep -q '"id"\|"name"\|"status"'; then
echo "✅ JSON output contains expected fields"
else
echo "❌ JSON output missing expected fields"
fi

echo "Testing: YAML output format"
YAML_OUTPUT=$($BINARY_PATH --hostname=localhost --port=4010 --output=yaml breeder list)
if echo "$YAML_OUTPUT" | grep -q -e '^-' -e 'id:' -e 'name:'; then
echo "✅ YAML output contains expected fields"
else
echo "❌ YAML output missing expected fields"
fi

echo "Testing: JSON output for breeder show"
$BINARY_PATH --hostname=localhost --port=4010 --output=json breeder show --id=550e8400-e29b-41d4-a716-446655440000

echo "Testing: YAML output for credential list"
$BINARY_PATH --hostname=localhost --port=4010 --output=yaml credential list

- name: Cleanup Prism container
if: always()
run: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Godon CLI

A Nim-based CLI tool for controlling and managing the Godon optimizer breeders via the Godon Control API.
A Rust-based CLI tool for controlling and managing the Godon optimizer breeders via the Godon Control API.

## Features

Expand Down Expand Up @@ -146,7 +146,7 @@ Create a YAML configuration file `credential.yaml`:

```yaml
name: "production_ssh_key"
credential_type: "ssh_private_key"
credentialType: "ssh_private_key"
description: "SSH key for production servers"
content: |
-----BEGIN RSA PRIVATE KEY-----
Expand Down
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,17 @@ async fn handle_breeder_command(client: &GodonClient, cmd: BreederCommands, outp

let response = client.update_breeder_from_yaml(&content).await;
if response.success {
if matches!(output, OutputFormat::Text) {
if let Some(ref data) = response.data {
let id = data.get("id").and_then(|v| v.as_str()).unwrap_or("unknown");
println!("Breeder updated successfully: {}", id);
if let Some(data) = response.data {
match data.get("id").and_then(|v| v.as_str()) {
Some(id) => {
if matches!(output, OutputFormat::Text) {
println!("Breeder updated successfully: {}", id);
} else {
format_output(&data, output);
}
}
None => write_error("Unexpected response format: missing 'id' field"),
}
} else if let Some(data) = response.data {
format_output(&data, output);
}
} else {
write_error(response.error.as_deref().unwrap_or("Unknown error"));
Expand Down
Loading