debian-mirror-gitlab/spec/lib/gitlab/kubernetes/role_binding_spec.rb

51 lines
1 KiB
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe Gitlab::Kubernetes::RoleBinding, '#generate' do
2018-12-13 13:39:08 +05:30
let(:role_name) { 'edit' }
2019-09-30 21:07:59 +05:30
let(:role_kind) { 'ClusterRole' }
2018-12-13 13:39:08 +05:30
let(:namespace) { 'my-namespace' }
let(:service_account_name) { 'my-service-account' }
let(:subjects) do
[
{
kind: 'ServiceAccount',
name: service_account_name,
namespace: namespace
}
]
end
let(:role_ref) do
{
apiGroup: 'rbac.authorization.k8s.io',
2019-09-30 21:07:59 +05:30
kind: role_kind,
2018-12-13 13:39:08 +05:30
name: role_name
}
end
let(:resource) do
::Kubeclient::Resource.new(
metadata: { name: "gitlab-#{namespace}", namespace: namespace },
roleRef: role_ref,
subjects: subjects
)
end
subject do
described_class.new(
name: "gitlab-#{namespace}",
role_name: role_name,
2019-09-30 21:07:59 +05:30
role_kind: role_kind,
2018-12-13 13:39:08 +05:30
namespace: namespace,
service_account_name: service_account_name
).generate
end
2019-07-07 11:18:12 +05:30
it 'builds a Kubeclient Resource' do
2018-12-13 13:39:08 +05:30
is_expected.to eq(resource)
end
end