github.com/miketheprogrammer/deis@v1.12.2/client/parser/utils_test.go (about)

     1  package parser
     2  
     3  import "testing"
     4  
     5  func TestSafeGet(t *testing.T) {
     6  	t.Parallel()
     7  
     8  	expected := "foo"
     9  
    10  	test := make(map[string]interface{}, 1)
    11  	test["test"] = "foo"
    12  
    13  	actual := safeGetValue(test, "test")
    14  
    15  	if expected != actual {
    16  		t.Errorf("Expected %s, Got %s", expected, actual)
    17  	}
    18  }
    19  
    20  func TestSafeGetNil(t *testing.T) {
    21  	t.Parallel()
    22  
    23  	expected := ""
    24  
    25  	test := make(map[string]interface{}, 1)
    26  	test["test"] = nil
    27  
    28  	actual := safeGetValue(test, "test")
    29  
    30  	if expected != actual {
    31  		t.Errorf("Expected %s, Got %s", expected, actual)
    32  	}
    33  }
    34  
    35  func TestPrintHelp(t *testing.T) {
    36  	t.Parallel()
    37  
    38  	usage := ""
    39  
    40  	if !printHelp([]string{"ps", "--help"}, usage) {
    41  		t.Error("Expected true")
    42  	}
    43  
    44  	if !printHelp([]string{"ps", "-h"}, usage) {
    45  		t.Error("Expected true")
    46  	}
    47  
    48  	if printHelp([]string{"ps"}, usage) {
    49  		t.Error("Expected false")
    50  	}
    51  
    52  	if printHelp([]string{"ps", "--foo"}, usage) {
    53  		t.Error("Expected false")
    54  	}
    55  }