Skip to content

Commit

Permalink
chore: linter fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Dec 11, 2024
1 parent a454d9c commit b4bb663
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
13 changes: 7 additions & 6 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"math/rand"
"os"
"path/filepath"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestClient(t *testing.T) {
require.NoError(t, err)

require.NoError(t, file.Close())
require.Equal(t, largerFileSize, len(buf.Bytes()))
require.Len(t, buf.Bytes(), largerFileSize)
})

t.Run("Open with Reader and consume file", func(t *testing.T) {
Expand All @@ -107,7 +108,7 @@ func TestClient(t *testing.T) {
require.NoError(t, err)

require.NoError(t, file.Close())
require.Equal(t, largerFileSize, len(buf.Bytes()))
require.Len(t, buf.Bytes(), largerFileSize)
})

t.Run("ListFiles", func(t *testing.T) {
Expand Down Expand Up @@ -168,9 +169,9 @@ func TestClient(t *testing.T) {
} else {
file, err = client.Reader(filenames[i])
}
require.NoError(t, err, fmt.Sprintf("filenames[%d]", i))
require.NotNil(t, file, fmt.Sprintf("filenames[%d]", i))
require.NotNil(t, file.Contents, fmt.Sprintf("filenames[%d]", i))
require.NoError(t, err, "filenames[%d]", i)
require.NotNil(t, file, "filenames[%d]", i)
require.NotNil(t, file.Contents, "filenames[%d]", i)

bs, err := io.ReadAll(file.Contents)
require.NoError(t, err)
Expand Down Expand Up @@ -296,7 +297,7 @@ func TestClient__UploadFile(t *testing.T) {
PacketSize: 32000,
}

subdir := fmt.Sprintf("%d", time.Now().UnixMilli())
subdir := strconv.FormatInt(time.Now().UnixMilli(), 10)
path := fmt.Sprintf("/upload/deep/nested/%s/file.txt", subdir)

t.Run("don't create subdir", func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion hostkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package go_sftp

import (
"bytes"
"errors"
"fmt"
"net"

Expand Down Expand Up @@ -32,5 +33,5 @@ func (m *MultiKeyCallback) check(_ string, _ net.Addr, key ssh.PublicKey) error
return nil
}
}
return fmt.Errorf("sftp: no matching host keys")
return errors.New("sftp: no matching host keys")
}
4 changes: 2 additions & 2 deletions network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ func TestNetwork(t *testing.T) {

files, err := client.ListFiles("/outbox")
require.NoError(t, err)
require.Greater(t, len(files), 0)
require.NotEmpty(t, files)

// close it again for fun
require.NoError(t, client.Close())

// try again
files, err = client.ListFiles("/outbox")
require.NoError(t, err)
require.Greater(t, len(files), 0)
require.NotEmpty(t, files)
})
}

0 comments on commit b4bb663

Please sign in to comment.