debian-mirror-gitlab/spec/lib/gitlab/kubernetes/kubeconfig/entry/cluster_spec.rb

24 lines
673 B
Ruby
Raw Normal View History

2021-10-27 15:23:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Kubernetes::Kubeconfig::Entry::Cluster do
describe '#to_h' do
let(:name) { 'name' }
let(:url) { 'url' }
subject { described_class.new(name: name, url: url).to_h }
it { is_expected.to eq({ name: name, cluster: { server: url } }) }
context 'with a certificate' do
let(:cert) { 'certificate' }
let(:cert_encoded) { Base64.strict_encode64(cert) }
subject { described_class.new(name: name, url: url, ca_pem: cert).to_h }
it { is_expected.to eq({ name: name, cluster: { server: url, 'certificate-authority-data': cert_encoded } }) }
end
end
end