Reduce differences in spec/support/helpers/kubernetes_helpers.rb

Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
Rémy Coutable 2019-02-26 18:14:00 +01:00
parent f5e80ed6b2
commit be44024c51
No known key found for this signature in database
GPG key ID: 98DFFD1C0C62B70B

View file

@ -9,6 +9,10 @@ module KubernetesHelpers
kube_response(kube_pods_body)
end
def kube_logs_response
kube_response(kube_logs_body)
end
def kube_deployments_response
kube_response(kube_deployments_body)
end
@ -34,6 +38,13 @@ module KubernetesHelpers
WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response)
end
def stub_kubeclient_logs(pod_name, response = nil)
stub_kubeclient_discover(service.api_url)
logs_url = service.api_url + "/api/v1/namespaces/#{service.actual_namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
WebMock.stub_request(:get, logs_url).to_return(response || kube_logs_response)
end
def stub_kubeclient_deployments(response = nil)
stub_kubeclient_discover(service.api_url)
deployments_url = service.api_url + "/apis/extensions/v1beta1/namespaces/#{service.actual_namespace}/deployments"
@ -212,6 +223,10 @@ module KubernetesHelpers
}
end
def kube_logs_body
"Log 1\nLog 2\nLog 3"
end
def kube_deployments_body
{
"kind" => "DeploymentList",