1package lib_test
2
3import (
4	"reflect"
5	"testing"
6
7	"github.com/warrensbox/terraform-switcher/lib"
8)
9
10// TestNewCommand : pass value and check if returned value is a pointer
11func TestNewCommand(t *testing.T) {
12
13	testCmd := "terraform"
14	cmd := lib.NewCommand(testCmd)
15
16	if reflect.ValueOf(cmd).Kind() == reflect.Ptr {
17		t.Logf("Value returned is a pointer %v [expected]", cmd)
18	} else {
19		t.Errorf("Value returned is not a pointer %v [expected", cmd)
20	}
21}
22
23// TestPathList : check if bin path exist
24func TestPathList(t *testing.T) {
25
26	testCmd := ""
27	cmd := lib.NewCommand(testCmd)
28	listBin := cmd.PathList()
29
30	if listBin == nil {
31		t.Error("No bin path found [unexpected]")
32	} else {
33		t.Logf("Found bin path [expected]")
34	}
35}
36
37type Command struct {
38	name string
39}
40
41// TestFind : check common "cd" command exist
42// This is assuming that Windows and linux has the "cd" command
43func TestFind(t *testing.T) {
44
45	testCmd := "cd"
46	cmd := lib.NewCommand(testCmd)
47
48	next := cmd.Find()
49	for path := next(); len(path) > 0; path = next() {
50		if path != "" {
51			t.Logf("Found installation path: %v [expected]\n", path)
52		} else {
53			t.Errorf("Unable to find '%v' command in this operating system [unexpected]", testCmd)
54		}
55	}
56}
57