From 0d494d044ef524346f1000b8abd8f701665ca858 Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Sat, 14 Feb 2026 08:46:49 -0800 Subject: [PATCH] test: add missing API assertion fixtures and body validation for 8 cloud providers (#1107) Added _api_assertions.sh fixtures for binarylane, genesiscloud, hyperstack, kamatera, latitude, ovh, scaleway, and upcloud to enable comprehensive mock test coverage. Updated _validate_body() in test/mock.sh to validate POST request bodies for all cloud providers, ensuring payload correctness. Fixed syntax error in gcore validation (!! to ;;). Co-authored-by: Spawn Refactor Service Co-authored-by: Claude Haiku 4.5 --- test/fixtures/binarylane/_api_assertions.sh | 2 ++ test/fixtures/genesiscloud/_api_assertions.sh | 2 ++ test/fixtures/hyperstack/_api_assertions.sh | 2 ++ test/fixtures/kamatera/_api_assertions.sh | 2 ++ test/fixtures/latitude/_api_assertions.sh | 2 ++ test/fixtures/ovh/_api_assertions.sh | 2 ++ test/fixtures/scaleway/_api_assertions.sh | 2 ++ test/fixtures/upcloud/_api_assertions.sh | 2 ++ test/mock.sh | 10 +++++++++- 9 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/binarylane/_api_assertions.sh create mode 100644 test/fixtures/genesiscloud/_api_assertions.sh create mode 100644 test/fixtures/hyperstack/_api_assertions.sh create mode 100644 test/fixtures/kamatera/_api_assertions.sh create mode 100644 test/fixtures/latitude/_api_assertions.sh create mode 100644 test/fixtures/ovh/_api_assertions.sh create mode 100644 test/fixtures/scaleway/_api_assertions.sh create mode 100644 test/fixtures/upcloud/_api_assertions.sh diff --git a/test/fixtures/binarylane/_api_assertions.sh b/test/fixtures/binarylane/_api_assertions.sh new file mode 100644 index 00000000..1a37952f --- /dev/null +++ b/test/fixtures/binarylane/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/account/keys" "fetches SSH keys" +assert_api_called "POST" "/servers" "creates server" diff --git a/test/fixtures/genesiscloud/_api_assertions.sh b/test/fixtures/genesiscloud/_api_assertions.sh new file mode 100644 index 00000000..0ff31fdb --- /dev/null +++ b/test/fixtures/genesiscloud/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/ssh-keys" "fetches SSH keys" +assert_api_called "POST" "/instances" "creates instance" diff --git a/test/fixtures/hyperstack/_api_assertions.sh b/test/fixtures/hyperstack/_api_assertions.sh new file mode 100644 index 00000000..6e36b37c --- /dev/null +++ b/test/fixtures/hyperstack/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/ssh-keys" "fetches SSH keys" +assert_api_called "POST" "/servers" "creates server" diff --git a/test/fixtures/kamatera/_api_assertions.sh b/test/fixtures/kamatera/_api_assertions.sh new file mode 100644 index 00000000..ef227032 --- /dev/null +++ b/test/fixtures/kamatera/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/svc/config/sshkey/list" "fetches SSH keys" +assert_api_called "POST" "/svc/server/create" "creates server" diff --git a/test/fixtures/latitude/_api_assertions.sh b/test/fixtures/latitude/_api_assertions.sh new file mode 100644 index 00000000..6e36b37c --- /dev/null +++ b/test/fixtures/latitude/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/ssh-keys" "fetches SSH keys" +assert_api_called "POST" "/servers" "creates server" diff --git a/test/fixtures/ovh/_api_assertions.sh b/test/fixtures/ovh/_api_assertions.sh new file mode 100644 index 00000000..96c9a077 --- /dev/null +++ b/test/fixtures/ovh/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/me/sshKey" "fetches SSH keys" +assert_api_called "POST" "/cloud/project" "interacts with cloud project" diff --git a/test/fixtures/scaleway/_api_assertions.sh b/test/fixtures/scaleway/_api_assertions.sh new file mode 100644 index 00000000..6c1bd5f6 --- /dev/null +++ b/test/fixtures/scaleway/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/sshkeys" "fetches SSH keys" +assert_api_called "POST" "/servers" "creates server" diff --git a/test/fixtures/upcloud/_api_assertions.sh b/test/fixtures/upcloud/_api_assertions.sh new file mode 100644 index 00000000..7da930b5 --- /dev/null +++ b/test/fixtures/upcloud/_api_assertions.sh @@ -0,0 +1,2 @@ +assert_api_called "GET" "/1.3/account" "fetches account info" +assert_api_called "POST" "/1.3/server" "creates server" diff --git a/test/mock.sh b/test/mock.sh index ee6e4128..a46ab155 100644 --- a/test/mock.sh +++ b/test/mock.sh @@ -299,9 +299,17 @@ _validate_body() { vultr) case "$EP_CLEAN" in /instances) _check_fields "label region plan os_id" ;; esac ;; linode) case "$EP_CLEAN" in /linode/instances) _check_fields "label region type image" ;; esac ;; civo) case "$EP_CLEAN" in /instances) _check_fields "hostname size region" ;; esac ;; + binarylane) case "$EP_CLEAN" in /servers) _check_fields "name region plan os_id" ;; esac ;; + upcloud) case "$EP_CLEAN" in /server) _check_fields "server" ;; esac ;; + genesiscloud) case "$EP_CLEAN" in /instances) _check_fields "name" ;; esac ;; + hyperstack) case "$EP_CLEAN" in /servers) _check_fields "name" ;; esac ;; + kamatera) case "$EP_CLEAN" in /server/create) _check_fields "datacenter" ;; esac ;; + latitude) case "$EP_CLEAN" in /servers) _check_fields "hostname site_id os_type" ;; esac ;; + ovh) case "$EP_CLEAN" in */create) _check_fields "name" ;; esac ;; + scaleway) case "$EP_CLEAN" in /servers) _check_fields "name" ;; esac ;; webdock) case "$EP_CLEAN" in /servers) _check_fields "name slug locationId profileSlug imageSlug" ;; esac ;; serverspace) case "$EP_CLEAN" in /servers) _check_fields "name location_id image_id cpu ram_mb" ;; esac ;; - gcore) case "$EP_CLEAN" in /instances) _check_fields "name flavor volumes interfaces" ;; esac !! + gcore) case "$EP_CLEAN" in /instances) _check_fields "name flavor volumes interfaces" ;; esac ;; esac }