diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/lib/gitlab/kubernetes/network_policy_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/lib/gitlab/kubernetes/network_policy_spec.rb')
-rw-r--r-- | spec/lib/gitlab/kubernetes/network_policy_spec.rb | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/spec/lib/gitlab/kubernetes/network_policy_spec.rb b/spec/lib/gitlab/kubernetes/network_policy_spec.rb index 5d1dd5dec59..d3640c61d94 100644 --- a/spec/lib/gitlab/kubernetes/network_policy_spec.rb +++ b/spec/lib/gitlab/kubernetes/network_policy_spec.rb @@ -7,21 +7,22 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do described_class.new( name: name, namespace: namespace, - creation_timestamp: '2020-04-14T00:08:30Z', - selector: pod_selector, - policy_types: %w(Ingress Egress), + selector: selector, ingress: ingress, - egress: egress + labels: labels ) end let(:resource) do ::Kubeclient::Resource.new( + kind: Gitlab::Kubernetes::NetworkPolicy::KIND, metadata: { name: name, namespace: namespace }, spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } ) end + let(:selector) { pod_selector } + let(:labels) { nil } let(:name) { 'example-name' } let(:namespace) { 'example-namespace' } let(:pod_selector) { { matchLabels: { role: 'db' } } } @@ -44,27 +45,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do ] end - include_examples 'network policy common specs' do - let(:selector) { pod_selector } - let(:policy) do - described_class.new( - name: name, - namespace: namespace, - selector: selector, - ingress: ingress, - labels: labels - ) - end - - let(:spec) { { podSelector: selector, policyTypes: ["Ingress"], ingress: ingress, egress: nil } } - let(:metadata) { { name: name, namespace: namespace } } - end - - describe '#generate' do - subject { policy.generate } - - it { is_expected.to eq(resource) } - end + include_examples 'network policy common specs' describe '.from_yaml' do let(:manifest) do @@ -180,6 +161,7 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do let(:generated_resource) do ::Kubeclient::Resource.new( + kind: Gitlab::Kubernetes::NetworkPolicy::KIND, metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } ) @@ -215,4 +197,31 @@ RSpec.describe Gitlab::Kubernetes::NetworkPolicy do it { is_expected.to be_nil } end end + + describe '#resource' do + subject { policy.resource } + + let(:resource) do + { + kind: Gitlab::Kubernetes::NetworkPolicy::KIND, + metadata: { name: name, namespace: namespace }, + spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } + } + end + + it { is_expected.to eq(resource) } + + context 'with labels' do + let(:labels) { { app: 'foo' } } + let(:resource) do + { + kind: Gitlab::Kubernetes::NetworkPolicy::KIND, + metadata: { name: name, namespace: namespace, labels: { app: 'foo' } }, + spec: { podSelector: pod_selector, policyTypes: %w(Ingress), ingress: ingress, egress: nil } + } + end + + it { is_expected.to eq(resource) } + end + end end |