mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-04 07:48:00 +08:00
Some checks failed
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / 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
Migrations / test (macos-latest) (push) Has been cancelled
Migrations / test (ubuntu-latest) (push) Has been cancelled
Migrations / test (windows-latest) (push) Has been cancelled
Signed-off-by: rifeplight <rifeplight@outlook.com>
46 lines
992 B
Go
46 lines
992 B
Go
package commands
|
|
|
|
import (
|
|
"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 := t.Context()
|
|
|
|
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)")
|
|
}
|