File: util_spec.rb

package info (click to toggle)
puppet-module-keystone 25.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 9,684; pascal: 295; python: 38; makefile: 10; sh: 10
file content (29 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'puppet'
require 'spec_helper'
require 'puppet/provider/keystone'
require 'puppet/provider/keystone/util'

describe "split_domain method" do
  it 'should handle nil and empty strings' do
    expect(Util.split_domain('')).to eq([nil, nil])
    expect(Util.split_domain(nil)).to eq([nil, nil])
  end
  it 'should return name and no domain' do
    expect(Util.split_domain('foo')).to eq(['foo', nil])
    expect(Util.split_domain('foo::')).to eq(['foo', nil])
  end
  it 'should return name and domain' do
    expect(Util.split_domain('foo::bar')).to eq(['foo', 'bar'])
    expect(Util.split_domain('foo::bar::')).to eq(['foo', 'bar'])
    expect(Util.split_domain('::foo::bar')).to eq(['::foo', 'bar'])
    expect(Util.split_domain('::foo::bar::')).to eq(['::foo', 'bar'])
    expect(Util.split_domain('foo::bar::baz')).to eq(['foo::bar', 'baz'])
    expect(Util.split_domain('foo::bar::baz::')).to eq(['foo::bar', 'baz'])
    expect(Util.split_domain('::foo::bar::baz')).to eq(['::foo::bar', 'baz'])
    expect(Util.split_domain('::foo::bar::baz::')).to eq(['::foo::bar', 'baz'])
  end
  it 'should return domain only' do
    expect(Util.split_domain('::foo')).to eq([nil, 'foo'])
    expect(Util.split_domain('::foo::')).to eq([nil, 'foo'])
  end
end