diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2018-07-25 08:52:06 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2018-07-25 08:52:06 +0300 |
commit | 06de83cc0f2282b2217c6151277dfd6789593c2e (patch) | |
tree | 8e7d013b2f66f9431b732f64fe8c8c5c8a87e7c5 /test/segments/ip.spec | |
parent | 99f0eddd62806f99b8116e3f327689bc32529d5d (diff) |
Prepare tests for performance optimizations
Diffstat (limited to 'test/segments/ip.spec')
-rwxr-xr-x | test/segments/ip.spec | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/test/segments/ip.spec b/test/segments/ip.spec index 0d07b6ee..190953ad 100755 --- a/test/segments/ip.spec +++ b/test/segments/ip.spec @@ -7,17 +7,18 @@ SHUNIT_PARENT=$0 function setUp() { export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme } function testIpSegmentPrintsNothingOnOsxIfNotConnected() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world) alias networksetup='echo "not connected"' - local OS="OSX" # Fake OSX local POWERLEVEL9K_CUSTOM_WORLD='echo world' + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS="OSX" # Fake OSX + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" unalias networksetup @@ -27,9 +28,12 @@ function testIpSegmentPrintsNothingOnLinuxIfNotConnected() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world) alias ip='echo "not connected"' - local OS="Linux" # Fake Linux local POWERLEVEL9K_CUSTOM_WORLD='echo world' + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS="Linux" # Fake Linux + assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)" unalias ip @@ -38,7 +42,6 @@ function testIpSegmentPrintsNothingOnLinuxIfNotConnected() { function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='OSX' # Fake OSX alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled. (1) Ethernet (Hardware Port: Ethernet, Device: en0) @@ -61,6 +64,10 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() { alias ipconfig="_(){ echo '1.2.3.4'; };_" + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='OSX' # Fake OSX + assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" unalias ipconfig @@ -74,7 +81,6 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() { function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='OSX' # Fake OSX alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled. (1) Ethernet (Hardware Port: Ethernet, Device: en0) @@ -113,6 +119,10 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() { } } + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='OSX' # Fake OSX + assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" unfunction ipconfig @@ -122,10 +132,13 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() { function testIpSegmentWorksOnOsxWithInterfaceSpecified() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='OSX' # Fake OSX local POWERLEVEL9K_IP_INTERFACE='xxx' alias ipconfig="_(){ echo '1.2.3.4'; };_" + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='OSX' # Fake OSX + assertEquals "%K{cyan} %F{black%}IP %f%F{black}1.2.3.4 %k%F{cyan}%f " "$(build_left_prompt)" unalias ipconfig @@ -134,7 +147,6 @@ function testIpSegmentWorksOnOsxWithInterfaceSpecified() { function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() { setopt aliases local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='Linux' # Fake Linux # That command is harder to test, as it is used at first # to get all relevant network interfaces and then for # getting the configuration of that segment.. @@ -151,18 +163,21 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() { inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever'; fi - } + } - assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='Linux' # Fake Linux - unfunction ip + assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" + + unfunction ip } function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() { setopt aliases local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='Linux' # Fake Linux # That command is harder to test, as it is used at first # to get all relevant network interfaces and then for # getting the configuration of that segment.. @@ -183,23 +198,30 @@ function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() { inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever'; fi - } + } - assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='Linux' # Fake Linux - unfunction ip + assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" + + unfunction ip } function testIpSegmentWorksOnLinuxWithInterfaceSpecified() { local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip) - local OS='Linux' # Fake Linux local POWERLEVEL9K_IP_INTERFACE='xxx' ip(){ echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0 valid_lft forever preferred_lft forever'; - } + } + + # Load Powerlevel9k + source powerlevel9k.zsh-theme + local OS='Linux' # Fake Linux assertEquals "%K{cyan} %F{black%}IP %f%F{black}10.0.2.15 %k%F{cyan}%f " "$(build_left_prompt)" |