Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 8baa363

Browse files
sethboylesjenspinney
authored andcommitted
Test internal domains when creating Route resource
* Adds a unit test to assert that if the domain associated with the CC route is internal, the generated Route resource in Kubernetes has the 'domain.internal' field set to true. [#171826991] Co-authored-by: Seth Boyles <sboyles@pivotal.io> Co-authored-by: Jen Spinney <jspinney@pivotal.io>
1 parent 1c34458 commit 8baa363

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

spec/unit/lib/kubernetes/route_crd_client_spec.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
describe '#create_route' do
66
let(:kube_client) { double(Kubeclient) }
77
let(:route) { VCAP::CloudController::Route.make }
8+
let(:internal_domain?) { route.internal? }
89
let(:route_crd_hash) do
910
{
1011
metadata: {
@@ -28,7 +29,7 @@
2829
url: route.fqdn,
2930
domain: {
3031
name: route.domain.name,
31-
internal: route.internal?
32+
internal: internal_domain?
3233
},
3334
destinations: []
3435
}
@@ -45,6 +46,22 @@
4546
expect(kube_client).to have_received(:create_route).with(Kubeclient::Resource.new(route_crd_hash)).once
4647
end
4748

49+
context 'when the domain is internal' do
50+
let(:internal_domain?) { true }
51+
52+
let(:space) { VCAP::CloudController::Space.make }
53+
let(:domain) { VCAP::CloudController::PrivateDomain.make(internal: true, owning_organization: space.organization) }
54+
let(:route) { VCAP::CloudController::Route.make(space: space, domain: domain) }
55+
56+
it 'sets internal to true' do
57+
allow(kube_client).to receive(:create_route).with(any_args)
58+
59+
subject.create_route(route)
60+
61+
expect(kube_client).to have_received(:create_route).with(Kubeclient::Resource.new(route_crd_hash)).once
62+
end
63+
end
64+
4865
context 'when there are k8s errors' do
4966
before do
5067
allow(kube_client).to receive(:create_route).and_raise(Kubeclient::HttpError.new(422, 'foo', 'bar'))

0 commit comments

Comments
 (0)