...

Source file src/github.com/shirou/gopsutil/host/host_linux_test.go

Documentation: github.com/shirou/gopsutil/host

     1  // +build linux
     2  
     3  package host
     4  
     5  import (
     6  	"testing"
     7  )
     8  
     9  func TestGetRedhatishVersion(t *testing.T) {
    10  	var ret string
    11  	c := []string{"Rawhide"}
    12  	ret = getRedhatishVersion(c)
    13  	if ret != "rawhide" {
    14  		t.Errorf("Could not get version rawhide: %v", ret)
    15  	}
    16  
    17  	c = []string{"Fedora release 15 (Lovelock)"}
    18  	ret = getRedhatishVersion(c)
    19  	if ret != "15" {
    20  		t.Errorf("Could not get version fedora: %v", ret)
    21  	}
    22  
    23  	c = []string{"Enterprise Linux Server release 5.5 (Carthage)"}
    24  	ret = getRedhatishVersion(c)
    25  	if ret != "5.5" {
    26  		t.Errorf("Could not get version redhat enterprise: %v", ret)
    27  	}
    28  
    29  	c = []string{""}
    30  	ret = getRedhatishVersion(c)
    31  	if ret != "" {
    32  		t.Errorf("Could not get version with no value: %v", ret)
    33  	}
    34  }
    35  
    36  func TestGetRedhatishPlatform(t *testing.T) {
    37  	var ret string
    38  	c := []string{"red hat"}
    39  	ret = getRedhatishPlatform(c)
    40  	if ret != "redhat" {
    41  		t.Errorf("Could not get platform redhat: %v", ret)
    42  	}
    43  
    44  	c = []string{"Fedora release 15 (Lovelock)"}
    45  	ret = getRedhatishPlatform(c)
    46  	if ret != "fedora" {
    47  		t.Errorf("Could not get platform fedora: %v", ret)
    48  	}
    49  
    50  	c = []string{"Enterprise Linux Server release 5.5 (Carthage)"}
    51  	ret = getRedhatishPlatform(c)
    52  	if ret != "enterprise" {
    53  		t.Errorf("Could not get platform redhat enterprise: %v", ret)
    54  	}
    55  
    56  	c = []string{""}
    57  	ret = getRedhatishPlatform(c)
    58  	if ret != "" {
    59  		t.Errorf("Could not get platform with no value: %v", ret)
    60  	}
    61  }
    62  

View as plain text