@@ -41,4 +41,40 @@ def test_process_template
41
41
data [ 'metadata' ] [ 'namespace' ] == 'default'
42
42
end
43
43
end
44
+
45
+ # Ensure _template and _templates methods hit `/templates` rather than
46
+ # `/processedtemplates` URL.
47
+ def test_templates_methods
48
+ stub_request ( :get , %r{/apis/template\. openshift\. io/v1$} ) . to_return (
49
+ body : open_test_file ( 'template.openshift.io_api_resource_list.json' ) ,
50
+ status : 200
51
+ )
52
+ client = Kubeclient ::Client . new ( 'http://localhost:8080/apis/template.openshift.io' , 'v1' )
53
+
54
+ expected_url = 'http://localhost:8080/apis/template.openshift.io/v1/namespaces/default/templates'
55
+ stub_request ( :get , expected_url )
56
+ . to_return ( body : open_test_file ( 'template_list.json' ) , status : 200 )
57
+ client . get_templates ( namespace : 'default' )
58
+ assert_requested ( :get , expected_url , times : 1 )
59
+
60
+ expected_url = 'http://localhost:8080/apis/template.openshift.io/v1/namespaces/default/templates/my-template'
61
+ stub_request ( :get , expected_url )
62
+ . to_return ( body : open_test_file ( 'template.json' ) , status : 200 )
63
+ client . get_template ( 'my-template' , 'default' )
64
+ assert_requested ( :get , expected_url , times : 1 )
65
+ end
66
+
67
+ def test_no_processedtemplates_methods
68
+ stub_request ( :get , %r{/apis/template\. openshift\. io/v1$} ) . to_return (
69
+ body : open_test_file ( 'template.openshift.io_api_resource_list.json' ) ,
70
+ status : 200
71
+ )
72
+ client = Kubeclient ::Client . new ( 'http://localhost:8080/apis/template.openshift.io' , 'v1' )
73
+ client . discover
74
+
75
+ refute_respond_to ( client , :get_processedtemplates )
76
+ refute_respond_to ( client , :get_processedtemplate )
77
+ refute_respond_to ( client , :get_processed_templates )
78
+ refute_respond_to ( client , :get_processed_template )
79
+ end
44
80
end
0 commit comments