mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 03:17:43 +08:00
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Build / docker-build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / go-test (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
Signed-off-by: Abhinav Prakash <abhinav.prakash319@gmail.com> Co-authored-by: Marcin Rataj <lidel@lidel.org> Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package commands
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"testing"
|
|
|
|
dag "github.com/ipfs/boxo/ipld/merkledag"
|
|
cmds "github.com/ipfs/go-ipfs-cmds"
|
|
coremock "github.com/ipfs/kubo/core/mock"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFilesCp_DagCborNodeFails(t *testing.T) {
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
defer cancel()
|
|
|
|
cmdCtx, err := coremock.MockCmdsCtx()
|
|
require.NoError(t, err)
|
|
|
|
node, err := cmdCtx.ConstructNode()
|
|
require.NoError(t, err)
|
|
|
|
invalidData := []byte{0x00}
|
|
protoNode := dag.NodeWithData(invalidData)
|
|
err = node.DAG.Add(ctx, protoNode)
|
|
require.NoError(t, err)
|
|
|
|
req := &cmds.Request{
|
|
Context: ctx,
|
|
Arguments: []string{
|
|
"/ipfs/" + protoNode.Cid().String(),
|
|
"/test-destination",
|
|
},
|
|
Options: map[string]interface{}{
|
|
"force": false,
|
|
},
|
|
}
|
|
|
|
_, pw := io.Pipe()
|
|
res, err := cmds.NewWriterResponseEmitter(pw, req)
|
|
require.NoError(t, err)
|
|
|
|
err = filesCpCmd.Run(req, res, &cmdCtx)
|
|
require.Error(t, err)
|
|
require.ErrorContains(t, err, "cp: source must be a valid UnixFS (dag-pb or raw codec)")
|
|
}
|