github.com/naphatkrit/deis@v1.12.3/client/deis_test.go (about)

     1  package main
     2  
     3  import (
     4  	"reflect"
     5  	"testing"
     6  )
     7  
     8  func TestHelpReformatting(t *testing.T) {
     9  	t.Parallel()
    10  
    11  	tests := []string{"--help", "-h", "help"}
    12  	expected := "help"
    13  
    14  	for _, test := range tests {
    15  		actual, argv := parseArgs([]string{test})
    16  
    17  		if actual != expected {
    18  			t.Errorf("Expected %s, Got %s", expected, actual)
    19  		}
    20  
    21  		if len(argv) != 1 {
    22  			t.Errorf("Expected length of 1, Got %d", len(argv))
    23  		}
    24  	}
    25  }
    26  
    27  func TestHelpReformattingWithCommand(t *testing.T) {
    28  	t.Parallel()
    29  
    30  	tests := []string{"--help", "-h", "help"}
    31  	expected := "test"
    32  	expectedArgv := []string{"test", "--help"}
    33  
    34  	for _, test := range tests {
    35  		actual, argv := parseArgs([]string{test, "test"})
    36  
    37  		if actual != expected {
    38  			t.Errorf("Expected %s, Got %s", expected, actual)
    39  		}
    40  
    41  		if !reflect.DeepEqual(expectedArgv, argv) {
    42  			t.Errorf("Expected %v, Got %v", expectedArgv, argv)
    43  		}
    44  	}
    45  }
    46  
    47  func TestCommandSplitting(t *testing.T) {
    48  	t.Parallel()
    49  
    50  	expected := "apps"
    51  	expectedArgv := []string{"apps:create", "test", "foo"}
    52  
    53  	actual, argv := parseArgs(expectedArgv)
    54  
    55  	if actual != expected {
    56  		t.Errorf("Expected %s, Got %s", expected, actual)
    57  	}
    58  
    59  	if !reflect.DeepEqual(expectedArgv, argv) {
    60  		t.Errorf("Expected %v, Got %v", expectedArgv, argv)
    61  	}
    62  }
    63  
    64  func TestReplaceShortcutRepalce(t *testing.T) {
    65  	t.Parallel()
    66  
    67  	expected := "apps:create"
    68  	actual := replaceShortcut("create")
    69  
    70  	if expected != actual {
    71  		t.Errorf("Expected %s, Got %s", expected, actual)
    72  	}
    73  }
    74  
    75  func TestReplaceShortcutUnchanged(t *testing.T) {
    76  	t.Parallel()
    77  
    78  	expected := "users:list"
    79  	actual := replaceShortcut(expected)
    80  
    81  	if expected != actual {
    82  		t.Errorf("Expected %s, Got %s", expected, actual)
    83  	}
    84  }