<commit_before>require 'spec_helper'

describe Puppet::Type.type(:brocade_alias_membership) do
  let(:title) { 'brocade_alias_membership' }

  context 'should compile with given test params' do
    let(:params) { {
        :alias_name   => 'DemoAlias',
        :member   => 'fdf8:f53e:61e4::18',
        :ensure   => 'present',
      }}
    it do
      expect {
        should compile
      }
    end

  end

  context "when validating attributes" do
    it "should have alias name as its keyattribute" do
      described_class.key_attributes.should == [:alias_name]
    end
    describe "when validating attributes" do
      [:alias_name, :member].each do |param|
        it "should hava a #{param} parameter" do
          described_class.attrtype(param).should == :param
        end
      end

      [:ensure].each do |property|
        it "should have a #{property} property" do
          described_class.attrtype(property).should == :property
        end
      end
    end
    describe "when validating values" do
      describe "validating alias_name param" do
        it "should allow a valid alias name" do
          described_class.new(:alias_name => 'alias_demo', :ensure => 'present',:member => 'fdf8:f53e:61e4::18')[:alias_name].should == 'alias_demo'
        end

        it "should not allow blank value in the alias name" do
          expect { described_class.new(:alias_name => '', :ensure => 'present',:member => 'fdf8:f53e:61e4::18') }.to raise_error Puppet::Error
        end
        it "should not allow special characters in the alias name" do
          expect { described_class.new(:alias_name => '$%^&!', :ensure => 'present',:member => 'fdf8:f53e:61e4::18') }.to raise_error Puppet::Error
        end
      end
      describe "validating ensure property" do
        it "should support present value" do
          described_class.new(:alias_name => 'DemoAlias', :member => 'fdf8:f53e:61e4::18', :ensure => 'present')[:ensure].should == :present
        end

        it "should support absent value" do
          described_class.new(:alias_name => 'DemoAlias', :member => 'fdf8:f53e:61e4::18', :ensure => 'absent')[:ensure].should == :absent
        end
        it "should not allow values other than present or absent" do
          expect { described_class.new(:alias_name => 'alias_demo', :ensure => 'foo',:member => 'fdf8:f53e:61e4::18') }.to raise_error Puppet::Error
        end

      end
      describe "validating member param" do
        it "should allow a valid member wwpn format to the given alias name" do
          described_class.new(:alias_name => 'alias_demo', :ensure => 'present',:member => 'fdf8:f53e:61e4::18')[:member].should == 'fdf8:f53e:61e4::18'
        end

        it "should not allow blank member name" do
          expect { described_class.new(:alias_name => 'alias_demo_new', :ensure => 'present',:member => '')}.to raise_error Puppet::Error
        end
        it "should not allow special char in the member value" do
          expect { described_class.new(:alias_name => 'alias_demo_new', :ensure => 'present',:member => '0%:0a:0a:0a:0a:0a:0a:0a') }.to raise_error Puppet::Error
        end
        it "should not allow invalid WWPN in the member value" do
          expect { described_class.new(:alias_name => 'alias_demo_new', :ensure => 'present',:member => '0f:0a:0a:0a:0a:0a:0a') }.to raise_error Puppet::Error
        end
      end
    end
  end
end<commit_msg>Alias membership rspec test for new parameter added<commit_after>require 'spec_helper'

describe Puppet::Type.type(:brocade_alias_membership) do
  let(:title) { 'brocade_alias_membership' }

  context 'should compile with given test params' do
    let(:params) { {
        :name   => 'DemoAlias:fdf8:f53e:61e4::18',
        :ensure   => 'present',
      }}
    it do
      expect {
        should compile
      }
    end

  end

  context "when validating attributes" do
    it "should have name as its keyattribute" do
      described_class.key_attributes.should == [:name]
    end
    
    describe "when validating attributes" do
      [:name,:alias_name, :member].each do |param|
        it "should hava a #{param} parameter" do
          described_class.attrtype(param).should == :param
        end
      end

      [:ensure].each do |property|
        it "should have a #{property} property" do
          described_class.attrtype(property).should == :property
        end
      end
    end
    
    describe "when validating values" do
      
      describe "validating name param" do
        it "should be a tuple of two values" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:name].should == 'alias_demo:fdf8:f53e:61e4::18'
        end
        
        it "should have alias name value before first splitter(:)" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:alias_name].should == 'alias_demo'
        end
        
        it "should have member value(s) after first splitter(:)" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:member].should == 'fdf8:f53e:61e4::18'
        end
        
      end
      describe "validating alias_name param" do
        it "should allow a valid alias name" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:alias_name].should == 'alias_demo'
        end

        it "should not allow blank value in the alias name" do
          expect { described_class.new(:name => ':fdf8:f53e:61e4::18', :ensure => 'present') }.to raise_error Puppet::Error
        end
        
        it "should not allow special characters in the alias name" do
          expect { described_class.new(:name => '@$%#^:fdf8:f53e:61e4::18', :ensure => 'present') }.to raise_error Puppet::Error
        end
      end
      describe "validating ensure property" do
        it "should support present value" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:ensure].should == :present
        end

        it "should support absent value" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'absent')[:ensure].should == :absent
        end
        it "should not allow values other than present or absent" do
          expect { described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'foo') }.to raise_error Puppet::Error
        end

      end
      describe "validating member param" do
        it "should allow a valid member wwpn format to the given alias name" do
          described_class.new(:name => 'alias_demo:fdf8:f53e:61e4::18', :ensure => 'present')[:member].should == 'fdf8:f53e:61e4::18'
        end

        it "should not allow blank member name" do
          expect { described_class.new(:name => 'alias_demo:', :ensure => 'present')}.to raise_error Puppet::Error
        end
        it "should not allow special char in the member value" do
          expect { described_class.new(:name => 'alias_demo:0f:0a:0a%0a:0a:0a:0a:0a', :ensure => 'present') }.to raise_error Puppet::Error
        end
        it "should not allow invalid WWPN in the member value" do
          expect { described_class.new(:name => 'alias_demo:0f:0a:0a:0a:0a:0a', :ensure => 'present') }.to raise_error Puppet::Error
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12647417649450995, 'fraction_numerical': 0.02887352582350549, 'mean_word_length': 2.8668763102725365, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 64, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4736118', 'n_tokens_mistral': 2394, 'n_tokens_neox': 2297, 'n_words': 627}