Sha256: bd7d3bb55cfa3331ed50c6d2fe8b84660dc57588964a32db7c369adf46c38c91

Contents?: true

Size: 1.97 KB

Versions: 19

Compression:

Stored size: 1.97 KB

Contents

#
# Copyright (C) 2008-2013 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
require "trema/link"


module Trema
  describe Link do
    before :each do
      Trema::Link.instances.clear
      @stanza = mock( "link stanza", :peers => [ "Virtual Host", "Virtual Switch" ] )
    end


    context "when creating/deleting a link" do
      before :each do
        @link = Link.new( @stanza )
      end


      it "executes ip and ifconfig command" do
        @link.should_receive( :sh ).once.ordered.with( "sudo ip link add name trema0-0 type veth peer name trema0-1" )
        @link.should_receive( :sh ).once.ordered.with( "sudo /sbin/sysctl -w net.ipv6.conf.trema0-0.disable_ipv6=1 >/dev/null 2>&1" )
        @link.should_receive( :sh ).once.ordered.with( "sudo /sbin/sysctl -w net.ipv6.conf.trema0-1.disable_ipv6=1 >/dev/null 2>&1" )
        @link.should_receive( :sh ).once.ordered.with( "sudo /sbin/ifconfig trema0-0 up" )
        @link.should_receive( :sh ).once.ordered.with( "sudo /sbin/ifconfig trema0-1 up" )

        @link.enable!
      end


      it "executes ip and ifconfig command" do
        @link.should_receive( :sh ).once.with( "sudo ip link delete trema0-0 2>/dev/null" )

        @link.delete!
      end
    end
  end
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End:

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
trema-0.4.6 spec/trema/link_spec.rb
trema-0.4.5 spec/trema/link_spec.rb
trema-0.4.4 spec/trema/link_spec.rb
trema-0.4.3 spec/trema/link_spec.rb
trema-0.4.2 spec/trema/link_spec.rb
trema-0.4.1 spec/trema/link_spec.rb
trema-0.4.0 spec/trema/link_spec.rb
trema-0.3.21 spec/trema/link_spec.rb
trema-0.3.20 spec/trema/link_spec.rb
trema-0.3.19 spec/trema/link_spec.rb
trema-0.3.18 spec/trema/link_spec.rb
trema-0.3.17 spec/trema/link_spec.rb
trema-0.3.16 spec/trema/link_spec.rb
trema-0.3.15 spec/trema/link_spec.rb
trema-0.3.14 spec/trema/link_spec.rb
trema-0.3.13 spec/trema/link_spec.rb
trema-0.3.12 spec/trema/link_spec.rb
trema-0.3.11 spec/trema/link_spec.rb
trema-0.3.10 spec/trema/link_spec.rb