diff --git a/cmd_test.go b/cmd_test.go index 32d4682..6684754 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -8,6 +8,7 @@ import ( "reflect" "testing" "time" + "path/filepath" ) type loggerT struct{} @@ -39,19 +40,6 @@ func TestRealize_Clean(t *testing.T) { } -func TestRealize_Check(t *testing.T) { - r := realize{} - err := r.check() - if err == nil { - t.Error("There is no project, error expected") - } - r.Schema = append(r.Schema, Project{Name: "test0"}) - err = r.check() - if err != nil { - t.Error("There is a project, error unexpected", err) - } -} - func TestRealize_Add(t *testing.T) { r := realize{} // add all flags, test with expected @@ -63,13 +51,13 @@ func TestRealize_Add(t *testing.T) { set.Bool("run", false, "") set.Bool("build", false, "") set.Bool("generate", false, "") - set.String("path", "", "") + set.String("path", wdir(), "") c := cli.NewContext(nil, set, nil) - set.Parse([]string{"--path=test_path", "--fmt", "--install", "--run", "--build", "--generate", "--test", "--vet"}) + set.Parse([]string{"--fmt", "--install", "--run", "--build", "--generate", "--test", "--vet"}) r.add(c) expected := Project{ - Name: "test_path", - Path: "test_path", + Name: filepath.Base(wdir()), + Path: wdir(), Cmds: Cmds{ Fmt: Cmd{ Status: true, @@ -93,7 +81,7 @@ func TestRealize_Add(t *testing.T) { }, Watcher: Watch{ Paths: []string{"/"}, - Ignore: []string{"vendor"}, + Ignore: []string{".git",".realize","vendor"}, Exts: []string{"go"}, }, } diff --git a/realize_test.go b/realize_test.go index f97ab25..f22439b 100644 --- a/realize_test.go +++ b/realize_test.go @@ -9,7 +9,7 @@ import ( func TestPrefix(t *testing.T) { input := random(10) - value := fmt.Sprint(yellow.bold("[")+"REALIZE"+yellow.bold("]"), input) + value := fmt.Sprint(yellow.bold("["), "REALIZE", yellow.bold("]"), " : ", input) result := prefix(input) if result == "" { t.Fatal("Expected a string") @@ -28,7 +28,6 @@ func TestBefore(t *testing.T) { func TestNew(t *testing.T) { r := new() - t.Log(reflect.TypeOf(r).String()) if reflect.TypeOf(r).String() != "main.realize" { t.Error("Expected a realize struct") } diff --git a/settings_test.go b/settings_test.go index b9092b5..cfe04e2 100644 --- a/settings_test.go +++ b/settings_test.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "os" "path/filepath" - "strings" "testing" ) @@ -100,18 +99,6 @@ func TestSettings_Record(t *testing.T) { s.del(filepath.Join(directory, s.file)) } -func TestSettings_Wdir(t *testing.T) { - s := Settings{} - expected, err := os.Getwd() - if err != nil { - t.Error(err) - } - result := s.wdir() - if result != filepath.Base(expected) { - t.Error("Expected", filepath.Base(expected), "instead", result) - } -} - func TestSettings_Validate(t *testing.T) { s := Settings{} input := errors.New("") @@ -121,28 +108,7 @@ func TestSettings_Validate(t *testing.T) { } } -func TestSettings_Name(t *testing.T) { +func TestSettings_Fatal(t *testing.T){ s := Settings{} - name := random(8) - path := random(5) - dir, err := os.Getwd() - if err != nil { - t.Fatal(err) - } - result := s.name(name, path) - if result != dir && result != filepath.Base(path) { - t.Fatal("Expected", dir, "or", filepath.Base(path), "instead", result) - } - -} - -func TestSettings_Path(t *testing.T) { - s := Settings{} - path := random(5) - expected := strings.Replace(filepath.Clean(path), "\\", "/", -1) - result := s.path(path) - if result != expected { - t.Fatal("Expected", expected, "instead", result) - } - -} + s.fatal(nil,"test") +} \ No newline at end of file diff --git a/utils_test.go b/utils_test.go index 728794a..84f6162 100644 --- a/utils_test.go +++ b/utils_test.go @@ -53,10 +53,13 @@ func TestInArray(t *testing.T) { } } -func TestGetEnvPath(t *testing.T) { - expected := filepath.SplitList(os.Getenv("GOPATH"))[0] - result := getEnvPath("GOPATH") - if expected != result { - t.Fatal("Expected", expected, "instead", result) +func TestWdir(t *testing.T) { + expected, err := os.Getwd() + if err != nil { + t.Error(err) + } + result := wdir() + if result != expected { + t.Error("Expected", filepath.Base(expected), "instead", result) } } diff --git a/watcher_test.go b/watcher_test.go index 394d1b2..223711f 100644 --- a/watcher_test.go +++ b/watcher_test.go @@ -29,7 +29,7 @@ func TestWalk(t *testing.T) { Ignore: []string{"vendor"}, Exts: []string{"go"}, }, - base: "/go/project", + Path: "/go/project", watcher: &fileWatcherMock{}, init: true, }