Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

cleanup: report test setup failures, fix staticcheck failures #244

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ipns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ import (
"time"
)

var examplesHashForIPNS = "/ipfs/Qmbu7x6gJbsKDcseQv66pSbUcAA3Au6f7MfTYVXwvBxN2K"
var testKey = "self" // feel free to change to whatever key you have locally
var (
//lint:ignore U1000 used only by skipped tests at present
examplesHashForIPNS = "/ipfs/Qmbu7x6gJbsKDcseQv66pSbUcAA3Au6f7MfTYVXwvBxN2K"
//lint:ignore U1000 used only by skipped tests at present
testKey = "self" // feel free to change to whatever key you have locally
)

func TestPublishDetailsWithKey(t *testing.T) {
t.Skip()
Expand Down
7 changes: 6 additions & 1 deletion mfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ func TestMain(m *testing.M) {
for _, f := range files {
file, err := os.Open(fmt.Sprintf("./testdata/%s", f))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to open test data file: %v\n", err)
os.Exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not a t.Fatal(err)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is before any test runs so we don't have access to a t yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I wasn’t aware of TestMain.

}

err = s.FilesWrite(context.Background(), fmt.Sprintf("/testdata/%s", f), file, FilesWrite.Parents(true), FilesWrite.Create(true))
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to write test data, not running tests: %v\n", err)
os.Exit(1)
}
}

exitVal := m.Run()
if err := s.FilesRm(context.Background(), "/testdata", true); err != nil {
fmt.Fprintf(os.Stderr, "Failed to remove test data: %v\n", err)
os.Exit(1)
}
os.Exit(exitVal)
Expand Down Expand Up @@ -115,7 +118,7 @@ func TestFilesMv(t *testing.T) {
is.Nil(err)
is.Equal(stat.Hash, "QmfZt7xPekp7npSM6DHDUnFseAiNZQs7wq6muH9o99RsCB")

stat, err = s.FilesStat(context.Background(), "/testdata/readme")
_, err = s.FilesStat(context.Background(), "/testdata/readme")
is.NotNil(err)

err = s.FilesMv(context.Background(), "/testdata/readme2", "/testdata/readme")
Expand Down Expand Up @@ -184,6 +187,8 @@ func TestFilesWrite(t *testing.T) {
is.Equal(string(resBytes), "ipfs")

file, err = ioutil.ReadFile("./testdata/ping")
is.Nil(err)

err = s.FilesWrite(context.Background(), "/testdata/ping", bytes.NewBuffer(file), FilesWrite.Offset(0), FilesWrite.Count(2), FilesWrite.Truncate(true))
is.Nil(err)

Expand Down
4 changes: 2 additions & 2 deletions shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
files "github.com/ipfs/go-ipfs-files"
homedir "github.com/mitchellh/go-homedir"
ma "github.com/multiformats/go-multiaddr"
manet "github.com/multiformats/go-multiaddr-net"
manet "github.com/multiformats/go-multiaddr/net"
tar "github.com/whyrusleeping/tar-utils"

p2pmetrics "github.com/libp2p/go-libp2p-core/metrics"
Expand Down Expand Up @@ -147,7 +147,7 @@ type IdOutput struct {
// return information about the local peer.
func (s *Shell) ID(peer ...string) (*IdOutput, error) {
if len(peer) > 1 {
return nil, fmt.Errorf("Too many peer arguments")
return nil, fmt.Errorf("too many peer arguments")
}

var out IdOutput
Expand Down