Skip to content

Commit

Permalink
chore: use assert.NoError instead of assert.Nil for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed May 16, 2023
1 parent 65b8d53 commit da28fbc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions test/cli/gateway_range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestGatewayHAMTDirectory(t *testing.T) {

// Import fixtures
r, err := os.Open("./fixtures/TestGatewayHAMTDirectory.car")
assert.Nil(t, err)
assert.NoError(t, err)
defer r.Close()
err = node.IPFSDagImport(r, fixtureCid)
assert.Nil(t, err)
assert.NoError(t, err)

// Fetch HAMT directory succeeds with minimal refs
resp := client.Get(fmt.Sprintf("/ipfs/%s/", hamtCid))
Expand All @@ -60,10 +60,10 @@ func TestGatewayMultiRange(t *testing.T) {

// Import fixtures
r, err := os.Open("./fixtures/TestGatewayMultiRange.car")
assert.Nil(t, err)
assert.NoError(t, err)
defer r.Close()
err = node.IPFSDagImport(r, fixtureCid)
assert.Nil(t, err)
assert.NoError(t, err)

// Succeeds fetching a range of blocks we have
resp := client.Get(fmt.Sprintf("/ipfs/%s", fileCid), func(r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions test/cli/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestGateway(t *testing.T) {
cid := node.IPFSAddStr("Hello Worlds!")

peerID, err := peer.ToCid(node.PeerID()).StringOfBase(multibase.Base36)
assert.Nil(t, err)
assert.NoError(t, err)

client := node.GatewayClient()
client.TemplateData = map[string]string{
Expand Down Expand Up @@ -480,7 +480,7 @@ func TestGateway(t *testing.T) {
})

node2PeerID, err := peer.ToCid(node2.PeerID()).StringOfBase(multibase.Base36)
assert.Nil(t, err)
assert.NoError(t, err)

nodes.StartDaemons().Connect()

Expand Down
8 changes: 4 additions & 4 deletions test/cli/swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestSwarm(t *testing.T) {
res := node.RunIPFS("swarm", "peers", "--enc=json", "--identify")
var output expectedOutputType
err := json.Unmarshal(res.Stdout.Bytes(), &output)
assert.Nil(t, err)
assert.NoError(t, err)
assert.Equal(t, 0, len(output.Peers))

})
Expand All @@ -48,7 +48,7 @@ func TestSwarm(t *testing.T) {
res := node.RunIPFS("swarm", "peers", "--enc=json", "--identify")
var output expectedOutputType
err := json.Unmarshal(res.Stdout.Bytes(), &output)
assert.Nil(t, err)
assert.NoError(t, err)
actualID := output.Peers[0].Identify.ID
actualPublicKey := output.Peers[0].Identify.PublicKey
actualAgentVersion := output.Peers[0].Identify.AgentVersion
Expand Down Expand Up @@ -78,12 +78,12 @@ func TestSwarm(t *testing.T) {
otherNodeIDResponse := otherNode.RunIPFS("id", "--enc=json")
var otherNodeIDOutput identifyType
err := json.Unmarshal(otherNodeIDResponse.Stdout.Bytes(), &otherNodeIDOutput)
assert.Nil(t, err)
assert.NoError(t, err)
res := node.RunIPFS("swarm", "peers", "--enc=json", "--identify")

var output expectedOutputType
err = json.Unmarshal(res.Stdout.Bytes(), &output)
assert.Nil(t, err)
assert.NoError(t, err)
outputIdentify := output.Peers[0].Identify

assert.Equal(t, outputIdentify.ID, otherNodeIDOutput.ID)
Expand Down

0 comments on commit da28fbc

Please sign in to comment.