from error to fatal

This commit is contained in:
alessio 2017-08-13 00:29:46 +02:00
parent bd9435693c
commit 4c18e2a630
3 changed files with 10 additions and 10 deletions

View File

@ -8,6 +8,6 @@ func TestSettings_Flimit(t *testing.T) {
s := Settings{} s := Settings{}
s.Config.Flimit = 1 s.Config.Flimit = 1
if err := s.Flimit(); err != nil { if err := s.Flimit(); err != nil {
t.Error("Unable to increase limit", err) t.Fatal("Unable to increase limit", err)
} }
} }

View File

@ -11,7 +11,7 @@ func TestSettings_Read(t *testing.T) {
var a interface{} var a interface{}
s.Resources.Config = "settings_b" s.Resources.Config = "settings_b"
if err := s.Read(a); err == nil { if err := s.Read(a); err == nil {
t.Error("Error unexpected", err) t.Fatal("Error unexpected", err)
} }
s.Resources.Config = "settings_test.yaml" s.Resources.Config = "settings_test.yaml"
@ -21,22 +21,22 @@ func TestSettings_Read(t *testing.T) {
} }
s.Resources.Config = d.Name() s.Resources.Config = d.Name()
if err := s.Read(a); err != nil { if err := s.Read(a); err != nil {
t.Error("Error unexpected", err) t.Fatal("Error unexpected", err)
} }
} }
func TestSettings_Remove(t *testing.T) { func TestSettings_Remove(t *testing.T) {
s := Settings{} s := Settings{}
if err := s.Remove("abcd"); err == nil { if err := s.Remove("abcd"); err == nil {
t.Error("Error unexpected, dir dosn't exist", err) t.Fatal("Error unexpected, dir dosn't exist", err)
} }
d, err := ioutil.TempDir("", "settings_test") d, err := ioutil.TempDir("", "settings_test")
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
if err := s.Remove(d); err != nil { if err := s.Remove(d); err != nil {
t.Error("Error unexpected, dir exist", err) t.Fatal("Error unexpected, dir exist", err)
} }
} }
@ -45,7 +45,7 @@ func TestSettings_Record(t *testing.T) {
s.Resources.Config = "settings_test.yaml" s.Resources.Config = "settings_test.yaml"
var a interface{} var a interface{}
if err := s.Record(a); err != nil { if err := s.Record(a); err != nil {
t.Error(err) t.Fatal(err)
} }
s.Remove(filepath.Join(Directory, s.Resources.Config)) s.Remove(filepath.Join(Directory, s.Resources.Config))
} }

View File

@ -36,11 +36,11 @@ func TestSettings_Name(t *testing.T) {
path := random.String(5) path := random.String(5)
dir, err := os.Getwd() dir, err := os.Getwd()
if err != nil { if err != nil {
t.Error(err) t.Fatal(err)
} }
result := s.Name(name, path) result := s.Name(name, path)
if result != dir && result != filepath.Base(path) { if result != dir && result != filepath.Base(path) {
t.Error("Expected", dir, "or", filepath.Base(path), "instead", result) t.Fatal("Expected", dir, "or", filepath.Base(path), "instead", result)
} }
} }
@ -51,7 +51,7 @@ func TestSettings_Path(t *testing.T) {
expected := strings.Replace(filepath.Clean(path), "\\", "/", -1) expected := strings.Replace(filepath.Clean(path), "\\", "/", -1)
result := s.Path(path) result := s.Path(path)
if result != expected { if result != expected {
t.Error("Expected", expected, "instead", result) t.Fatal("Expected", expected, "instead", result)
} }
} }