Skip to content

Commit ffd72a9

Browse files
added tests for unbind-route-service
1 parent c3b1bee commit ffd72a9

4 files changed

Lines changed: 62 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111

1212
- Introduced new tests (see `spec` folder) using the [shellspec](https://shellspec.info/) BDD testing framework. The existing home-grown test framework in the `itest` folder has served this project well, but it's time to move on to something better. Over the upcoming releases, we'll slowly start converting more of the `itest` tests to the newer `spec` tests.
13-
- `push` command now supports specifying multiple `buildpacks`, thanks to a PR by [tenjaa](https://github.com/tenjaa). The original `buildpack` option is now deprecated and superceded by `buildpacks`.
13+
- `unbind-route-service` - Unbind a service instance from an HTTP route, thanks to a PR by [JHjava](https://github.com/JHjava)
1414

1515
### Changed
1616

17+
- `push` command now supports specifying multiple `buildpacks`, thanks to a PR by [tenjaa](https://github.com/tenjaa). The original `buildpack` option is now deprecated and superceded by `buildpacks`.
1718
- Resource and test executions are now isolated from each other thanks to setting their own unique `CF_HOME` locations.
1819

1920
### Packaged Dependencies

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,28 @@ Bind a service instance to an HTTP route
755755
path: foo
756756
```
757757

758+
#### unbind-route-service
759+
760+
Unbind a service instance from an HTTP route
761+
762+
- `org`: _Optional._ The organization to target (required if not set in the source config)
763+
- `space`: _Optional._ The space to target (required if not set in the source config)
764+
- `domain`: _Required._ The domain to unbind the route from
765+
- `service_instance`: _Required._ The service instance to unbind the route from
766+
- `hostname`: _Optional._ Hostname used in combination with DOMAIN to specify the route to unbind
767+
- `path`: _Optional._ Path used in combination with HOSTNAME and DOMAIN to specify the route to unbind
768+
769+
```yml
770+
- put: cf-unbind-route-service
771+
resource: cf-env
772+
params:
773+
command: unbind-route-service
774+
domain: example.com
775+
service_instance: mylogger
776+
hostname: myhost
777+
path: foo
778+
```
779+
758780
#### enable-feature-flag
759781

760782
Allow use of a feature

itest/run-route-service-tests

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,40 @@ it_can_bind_logger_route_service_to_logged_app() {
106106
fi
107107
}
108108

109+
it_can_unbind_logger_route_service_from_logged_app() {
110+
local org=${1:?org null or not set}
111+
local space=${2:?space null or not set}
112+
local domain=${3:?domain null or not set}
113+
local service_instance=${4:?service_instance null or not set}
114+
local app_name=${5:?app_name null or not set}
115+
local path=${6:-}
116+
117+
local params=$(jq -n \
118+
--arg org "$org" \
119+
--arg space "$space" \
120+
--arg domain "$domain" \
121+
--arg service_instance "$service_instance" \
122+
--arg hostname "$(app_to_hostname "$app_name")" \
123+
'{
124+
command: "unbind-route-service",
125+
org: $org,
126+
space: $space,
127+
domain: $domain,
128+
service_instance: $service_instance,
129+
hostname: $hostname
130+
}')
131+
132+
[ -n "$path" ] && params=$(echo $params | jq --arg value "$path" '.path = $value')
133+
134+
put_with_params "$CCR_SOURCE" "$params" | jq -e '.version | keys == ["timestamp"]'
135+
136+
if [ -n "$path" ]; then
137+
assert::failure cf::is_app_bound_to_route_service "$app_name" "$service_instance" "$org" "$space" "/$path"
138+
else
139+
assert::failure cf::is_app_bound_to_route_service "$app_name" "$service_instance" "$org" "$space"
140+
fi
141+
}
142+
109143
org=$(generate_test_name_with_spaces "Org")
110144
space=$(generate_test_name_with_spaces "Space")
111145
logger_app_name=$(generate_test_name_with_spaces "Logger")
@@ -130,4 +164,7 @@ run it_can_push_the_app_to_be_logged \"$org\" \"$space\" \"$logged_app_name\" \"
130164
run it_can_bind_logger_route_service_to_logged_app \"$org\" \"$space\" \"$domain\" \"$service_instance\" \"$logged_app_name\"
131165
run it_can_bind_logger_route_service_to_logged_app \"$org\" \"$space\" \"$domain\" \"$service_instance\" \"$logged_app_name\" \"$logged_app_path\"
132166

167+
run it_can_unbind_logger_route_service_from_logged_app \"$org\" \"$space\" \"$domain\" \"$service_instance\" \"$logged_app_name\" \"$logged_app_path\"
168+
run it_can_unbind_logger_route_service_from_logged_app \"$org\" \"$space\" \"$domain\" \"$service_instance\" \"$logged_app_name\"
169+
133170
teardown_integration_tests "$org" "$space"

resource/commands/unbind-route-service.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ args=("$domain" "$service_instance")
1212
[ -n "$hostname" ] && args+=(--hostname "$hostname")
1313
[ -n "$path" ] && args+=(--path "$path")
1414

15-
cf::cf unbind-route-service "${args[@]}"
15+
cf::cf unbind-route-service -f "${args[@]}"

0 commit comments

Comments
 (0)