source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 7 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 2.6 KB
Line 
1#! /usr/bin/env ruby -S rspec
2require 'spec_helper'
3
4describe "the enclose_ipv6 function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7 it "should exist" do
8 expect(Puppet::Parser::Functions.function("enclose_ipv6")).to eq("function_enclose_ipv6")
9 end
10
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_enclose_ipv6([]) }.to( raise_error(Puppet::ParseError) )
13 end
14
15 it "should raise a ParseError if there is more than 1 arguments" do
16 expect { scope.function_enclose_ipv6(['argument1','argument2']) }.to( raise_error(Puppet::ParseError) )
17 end
18
19 it "should raise a ParseError when given garbage" do
20 expect { scope.function_enclose_ipv6(['garbage']) }.to( raise_error(Puppet::ParseError) )
21 end
22
23 it "should raise a ParseError when given something else than a string or an array" do
24 expect { scope.function_enclose_ipv6([['1' => '127.0.0.1']]) }.to( raise_error(Puppet::ParseError) )
25 end
26
27 it "should not raise a ParseError when given a single ip string" do
28 expect { scope.function_enclose_ipv6(['127.0.0.1']) }.to_not raise_error
29 end
30
31 it "should not raise a ParseError when given * as ip string" do
32 expect { scope.function_enclose_ipv6(['*']) }.to_not raise_error
33 end
34
35 it "should not raise a ParseError when given an array of ip strings" do
36 expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1']]) }.to_not raise_error
37 end
38
39 it "should not raise a ParseError when given differently notations of ip addresses" do
40 expect { scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::1]']]) }.to_not raise_error
41 end
42
43 it "should raise a ParseError when given a wrong ipv4 address" do
44 expect { scope.function_enclose_ipv6(['127..0.0.1']) }.to( raise_error(Puppet::ParseError) )
45 end
46
47 it "should raise a ParseError when given a ipv4 address with square brackets" do
48 expect { scope.function_enclose_ipv6(['[127.0.0.1]']) }.to( raise_error(Puppet::ParseError) )
49 end
50
51 it "should raise a ParseError when given a wrong ipv6 address" do
52 expect { scope.function_enclose_ipv6(['fe80:::1']) }.to( raise_error(Puppet::ParseError) )
53 end
54
55 it "should embrace ipv6 adresses within an array of ip addresses" do
56 result = scope.function_enclose_ipv6([['127.0.0.1','fe80::1','[fe80::2]']])
57 expect(result).to(eq(['127.0.0.1','[fe80::1]','[fe80::2]']))
58 end
59
60 it "should embrace a single ipv6 adresse" do
61 result = scope.function_enclose_ipv6(['fe80::1'])
62 expect(result).to(eq(['[fe80::1]']))
63 end
64
65 it "should not embrace a single ipv4 adresse" do
66 result = scope.function_enclose_ipv6(['127.0.0.1'])
67 expect(result).to(eq(['127.0.0.1']))
68 end
69end
Note: See TracBrowser for help on using the repository browser.