Skip to content

Commit

Permalink
Add tests for non-suffix y->ies plurals ManageIQ#376
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Dec 15, 2018
1 parent 55b8fe0 commit e439ee4
Show file tree
Hide file tree
Showing 2 changed files with 229 additions and 0 deletions.
217 changes: 217 additions & 0 deletions test/json/extensions_v1beta1_api_resource_list.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
{
"kind": "APIResourceList",
"groupVersion": "extensions/v1beta1",
"resources": [
{
"name": "daemonsets",
"singularName": "",
"namespaced": true,
"kind": "DaemonSet",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"ds"
]
},
{
"name": "daemonsets/status",
"singularName": "",
"namespaced": true,
"kind": "DaemonSet",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "deployments",
"singularName": "",
"namespaced": true,
"kind": "Deployment",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"deploy"
]
},
{
"name": "deployments/rollback",
"singularName": "",
"namespaced": true,
"kind": "DeploymentRollback",
"verbs": [
"create"
]
},
{
"name": "deployments/scale",
"singularName": "",
"namespaced": true,
"group": "extensions",
"version": "v1beta1",
"kind": "Scale",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "deployments/status",
"singularName": "",
"namespaced": true,
"kind": "Deployment",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "ingresses",
"singularName": "",
"namespaced": true,
"kind": "Ingress",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"ing"
]
},
{
"name": "ingresses/status",
"singularName": "",
"namespaced": true,
"kind": "Ingress",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "networkpolicies",
"singularName": "",
"namespaced": true,
"kind": "NetworkPolicy",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"netpol"
]
},
{
"name": "podsecuritypolicies",
"singularName": "",
"namespaced": false,
"kind": "PodSecurityPolicy",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"psp"
]
},
{
"name": "replicasets",
"singularName": "",
"namespaced": true,
"kind": "ReplicaSet",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
],
"shortNames": [
"rs"
]
},
{
"name": "replicasets/scale",
"singularName": "",
"namespaced": true,
"group": "extensions",
"version": "v1beta1",
"kind": "Scale",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "replicasets/status",
"singularName": "",
"namespaced": true,
"kind": "ReplicaSet",
"verbs": [
"get",
"patch",
"update"
]
},
{
"name": "replicationcontrollers",
"singularName": "",
"namespaced": true,
"kind": "ReplicationControllerDummy",
"verbs": []
},
{
"name": "replicationcontrollers/scale",
"singularName": "",
"namespaced": true,
"kind": "Scale",
"verbs": [
"get",
"patch",
"update"
]
}
]
}
12 changes: 12 additions & 0 deletions test/test_missing_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ def test_missing
end
end

def test_nonsuffix_plurals
stub_request(:get, %r{/apis/extensions/v1beta1$}).to_return(
body: open_test_file('extensions_v1beta1_api_resource_list.json'),
status: 200
)
client = Kubeclient::Client.new('http://localhost:8080/apis/extensions', 'v1beta1')
assert_equal(true, client.respond_to?(:get_network_policy))
assert_equal(true, client.respond_to?(:get_network_policies))
assert_equal(true, client.respond_to?(:get_pod_security_policy))
assert_equal(true, client.respond_to?(:get_pod_security_policies))
end

def test_irregular_names
stub_core_api_list
client = Kubeclient::Client.new('http://localhost:8080/api/', 'v1')
Expand Down

0 comments on commit e439ee4

Please sign in to comment.