Skip to content

Commit

Permalink
Updated testsuite for CanonicalizeIP.
Browse files Browse the repository at this point in the history
Ported existing tests from old testsuite into new one and added testcase
based on bnc#837517
  • Loading branch information
mchf committed Sep 11, 2013
1 parent 6a76a65 commit 02dbad5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
33 changes: 33 additions & 0 deletions library/network/test/load_ipv6_cfg_test.rb
@@ -0,0 +1,33 @@
#! /usr/bin/env ruby

require "minitest/spec"
require "minitest/autorun"

require "yast"

Yast.import "NetworkInterfaces"

# mocked IPv6 relevant part of loaded ifcfg
IPV6_IFCFG = [
{
:data => { "IPADDR" => "2001:15c0:668e::5", "PREFIXLEN" => "48" },
:expected => { "IPADDR" => "2001:15c0:668e::5", "PREFIXLEN" => "48", "NETMASK" => "" }
},
{
:data => { "IPADDR" => "2001:15c0:668e::5/48", "PREFIXLEN" => "" },
:expected => { "IPADDR" => "2001:15c0:668e::5", "PREFIXLEN" => "48", "NETMASK" => "" }
},
{
:data => { "IPADDR" => "2a00:8a00:6000:40::451", "PREFIXLEN" => "119" },
:expected => { "IPADDR" => "2a00:8a00:6000:40::451", "PREFIXLEN" => "119", "NETMASK" => "" }
}
]

describe "When reading devices configuration with IPv6 setup" do
it "Sets ipaddr, prefix and empty mask" do
IPV6_IFCFG.each do |ipv6_ifcfg|
canonical_ifcfg = Yast::NetworkInterfaces.CanonicalizeIP( ipv6_ifcfg[ :data])
canonical_ifcfg.must_equal( ipv6_ifcfg[ :expected])
end
end
end
2 changes: 0 additions & 2 deletions library/network/testsuite/tests/NetworkInterfaces.out
Expand Up @@ -32,5 +32,3 @@ Return $["IPADDR":"10.0.0.1", "NETMASK":"255.0.0.0", "PREFIXLEN":"8", "other":"d
Return nil
Return $[]
Return $["IPADDR":"10.0.0.1", "NETMASK":"255.255.255.255", "PREFIXLEN":"32", "other":"data"]
Return $["IPADDR":"2001:15c0:668e::5", "NETMASK":"", "PREFIXLEN":"48"]
Return $["IPADDR":"2001:15c0:668e::5", "NETMASK":"", "PREFIXLEN":"48"]
3 changes: 0 additions & 3 deletions library/network/testsuite/tests/NetworkInterfaces.rb
Expand Up @@ -80,9 +80,6 @@ def main
nil,
{},
{ "IPADDR" => "10.0.0.1", "other" => "data" },
# IPv6
{ "IPADDR" => "2001:15c0:668e::5", "PREFIXLEN" => "48" },
{ "IPADDR" => "2001:15c0:668e::5/48", "PREFIXLEN" => "" }
]
Builtins.foreach(@addresses) { |address| TEST(lambda do
NetworkInterfaces.CanonicalizeIP(address)
Expand Down

0 comments on commit 02dbad5

Please sign in to comment.