1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
# frozen_string_literal: true
require_relative 'test_helper'
# Replication Controller entity tests
class TestReplicationController < Minitest::Test
def test_get_from_json_v1
stub_core_api_list
stub_request(:get, %r{/replicationcontrollers})
.to_return(body: open_test_file('replication_controller.json'),
status: 200)
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
rc = client.get_replication_controller('frontendController', 'default')
assert_instance_of(Kubeclient::Resource, rc)
assert_equal('guestbook-controller', rc.metadata.name)
assert_equal('c71aa4c0-a240-11e4-a265-3c970e4a436a', rc.metadata.uid)
assert_equal('default', rc.metadata.namespace)
assert_equal(3, rc.spec.replicas)
assert_equal('guestbook', rc.spec.selector.name)
assert_requested(:get,
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController',
times: 1)
end
def test_delete_replicaset_cascade
stub_core_api_list
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
opts = Kubeclient::Resource.new(
apiVersion: 'meta/v1',
gracePeriodSeconds: 0,
kind: 'DeleteOptions',
propagationPolicy: 'Foreground'
)
stub_request(:delete,
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController')
.with(body: opts.to_hash.to_json)
.to_return(status: 200, body: open_test_file('replication_controller.json'), headers: {})
rc = client.delete_replication_controller('frontendController', 'default', delete_options: opts)
assert_kind_of(RecursiveOpenStruct, rc)
assert_requested(:delete,
'http://localhost:8080/api/v1/namespaces/default/replicationcontrollers/frontendController',
times: 1)
end
end
|