refactoring all tests but handlers and process

This commit is contained in:
Julien Neuhart
2018-04-11 13:30:02 +02:00
parent 6b5a214462
commit a1abbc55a2
6 changed files with 84 additions and 70 deletions

View File

@@ -12,17 +12,17 @@ func TestNewFile(t *testing.T) {
workingDir := "test"
os.Mkdir(workingDir, 0666)
// case 2: uses a wrong file name.
// case 1: uses a wrong file name.
if _, err := NewFile(workingDir, new(bytes.Buffer), "file.yml"); err == nil {
t.Error("File should not have been instantiated!")
t.Error("File should not have been instantiated with an empty buffer")
}
// case 3: uses a reader from a correct file type.
// case 2: uses a reader from a correct file type.
filePath, _ := filepath.Abs("../../../_tests/file.pdf")
r, _ := os.Open(filePath)
defer r.Close()
if _, err := NewFile(workingDir, r, "file.pdf"); err != nil {
t.Error("File should have been instantiated!")
t.Errorf("File should have been instantiated using a reader from '%s'", filePath)
}
os.RemoveAll(workingDir)
@@ -31,8 +31,7 @@ func TestFileTypeNotFoundError(t *testing.T) {
fileName := "file.wp"
err := &fileTypeNotFoundError{fileName: fileName}
expected := fmt.Sprintf("File type was not found for '%s'", fileName)
if err.Error() != expected {
t.Errorf("Error returned a wrong message: got %s want %s", err.Error(), expected)
t.Errorf("Error returned a wrong message: got '%s' want '%s'", err.Error(), expected)
}
}