Skip to content

Commit

Permalink
added test cases for command_test
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed May 22, 2018
1 parent 30c5d7c commit d3fc91f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions lib/command_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package lib_test

import (
"reflect"
"testing"

"github.com/warren-veerasingam/terraform-switcher/lib"
)

// TestNewCommand : pass value and check if returned value is a pointer
func TestNewCommand(t *testing.T) {

testCmd := "terraform"
cmd := lib.NewCommand(testCmd)

if reflect.ValueOf(cmd).Kind() == reflect.Ptr {
t.Logf("Value returned is a pointer %v [expected]", cmd)
} else {
t.Errorf("Value returned is not a pointer %v [expected", cmd)
}
}

// TestPathList : check if bin path exist
func TestPathList(t *testing.T) {

testCmd := ""
cmd := lib.NewCommand(testCmd)
listBin := cmd.PathList()

if listBin == nil {
t.Error("No bin path found [unexpected]")
} else {
t.Logf("Found bin path [expected]")
}
}

type Command struct {
name string
}

// TestFind : check common "cd" command exist
// This is assuming that Windows and linux has the "cd" command
func TestFind(t *testing.T) {

testCmd := "cd"
cmd := lib.NewCommand(testCmd)

next := cmd.Find()
for path := next(); len(path) > 0; path = next() {
if path != "" {
t.Logf("Found installation path: %v [expected]\n", path)
} else {
t.Errorf("Unable to find '%v' command in this operating system [unexpected]", testCmd)
}
}
}

0 comments on commit d3fc91f

Please sign in to comment.