forked from fclairamb/ftpserverlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
29 lines (25 loc) · 872 Bytes
/
errors_test.go
File metadata and controls
29 lines (25 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package ftpserver
import (
"bufio"
"bytes"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCustomErrorsCode(t *testing.T) {
code := getErrorCode(ErrStorageExceeded, StatusActionNotTaken)
assert.Equal(t, StatusActionAborted, code)
code = getErrorCode(ErrFileNameNotAllowed, StatusActionNotTaken)
assert.Equal(t, StatusActionNotTakenNoFile, code)
code = getErrorCode(os.ErrPermission, StatusActionNotTaken)
assert.Equal(t, StatusActionNotTaken, code)
code = getErrorCode(os.ErrClosed, StatusNotLoggedIn)
assert.Equal(t, StatusNotLoggedIn, code)
}
func TestTransferCloseStorageExceeded(t *testing.T) {
buf := bytes.Buffer{}
h := clientHandler{writer: bufio.NewWriter(&buf)}
h.TransferClose(ErrStorageExceeded)
require.Equal(t, "552 Issue during transfer: storage limit exceeded\r\n", buf.String())
}