Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f8a2fe5
fix::> Added checks for UnixFS + added force flag
PsychoPunkSage Feb 6, 2025
9db46b1
docs: update min requirements (#10687)
lidel Feb 5, 2025
3031cf3
docs(release): update RELEASE_CHECKLIST.md after v0.33.1 (#10697)
lidel Feb 5, 2025
b28bce9
Merge branch 'master' into issue-10331
PsychoPunkSage Feb 6, 2025
e922ef0
fix::> Removed confusing shorthand
PsychoPunkSage Feb 15, 2025
3297308
fix::> impl changes
PsychoPunkSage Feb 15, 2025
4a8bb62
fix::> Basic Setup of Tests
PsychoPunkSage Feb 15, 2025
a687b2b
fix::> test 1
PsychoPunkSage Feb 15, 2025
de94ec6
fix::> test passing
PsychoPunkSage Feb 15, 2025
58e4c90
fix::> formatting
PsychoPunkSage Feb 16, 2025
8e6796f
fix::> Proper test env ready
PsychoPunkSage Feb 16, 2025
fa7c769
fix::> Proper test ready
PsychoPunkSage Feb 16, 2025
1296054
fix::> Test Passing
PsychoPunkSage Feb 19, 2025
888e1e8
Merge branch 'master' into issue-10331
gammazero Feb 20, 2025
8ab8a83
Rename files cp "force" option to "no-validate"
gammazero Feb 20, 2025
d945049
Use require package for more compact test code
gammazero Feb 20, 2025
34f05a2
Rename file_test.go to files_test.go to match the files command
gammazero Feb 20, 2025
b77142d
Update core/commands/files.go
PsychoPunkSage Feb 27, 2025
9f7f8b6
Update core/commands/files.go
PsychoPunkSage Feb 27, 2025
9a59b8d
Update core/commands/files.go
PsychoPunkSage Feb 27, 2025
7ad6847
fix::> Added dedicated tests....
PsychoPunkSage Feb 27, 2025
548f630
fix::> more random tests
PsychoPunkSage Feb 27, 2025
5c93132
refactor: remove --force, simplify checks
lidel Mar 5, 2025
bf04ec1
Merge branch 'master' into issue-10331
lidel Mar 5, 2025
23c8b6e
docs: changelog
lidel Mar 5, 2025
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
Prev Previous commit
Next Next commit
fix::> Proper test ready
Signed-off-by: Abhinav Prakash <[email protected]>
  • Loading branch information
PsychoPunkSage committed Feb 16, 2025
commit fa7c7695df9f88f01a4bfc87b77ca26c80f2712c
92 changes: 14 additions & 78 deletions core/commands/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,36 @@ import (
"strings"
"testing"

dag "github.com/ipfs/boxo/ipld/merkledag"
cmds "github.com/ipfs/go-ipfs-cmds"
coremock "github.com/ipfs/kubo/core/mock"
)

// type testenv struct {
// ctx context.Context
// node *core.IpfsNode
// reqchan chan<- string
// }

// type writeCloser struct {
// *bytes.Buffer
// }

// func (w writeCloser) Close() error { return nil }

// func createTestEnv(t *testing.T, ctx context.Context) cmds.Environment {
// ds := sync.MutexWrap(datastore.NewMapDatastore())
// node, err := core.NewNode(ctx, &core.BuildCfg{
// Online: false,
// Repo: &repo.Mock{
// C: config.Config{
// Identity: config.Identity{
// PeerID: "QmTFauExutTsy4XP6JbMFcw2Wa9645HJt2bTqL6qYDCKfe",
// },
// },
// D: ds,
// },
// })
// require.NoError(t, err)

// return &testenv{
// ctx: ctx,
// node: node,
// }

// }

// func TestCopyCBORtoMFS(t *testing.T) {
// // mock environment creation
// ctx := context.Background()
// env := createTestEnv(t, ctx)

// cborCid := "bafyreigbtj4x7ip5legnfznufuopl4sg4knzc2cof6duas4b3q2fy6swua"

// req := &cmds.Request{
// Context: ctx,
// Arguments: []string{
// "/ipfs/" + cborCid,
// "/test-cbor",
// },
// Options: map[string]interface{}{
// filesFlushOptionName: true,
// },
// }

// // mock response emitter
// w := writeCloser{new(bytes.Buffer)}
// require.NoError(t, err, "creating response emitter should not fail")

// err = filesCpCmd.Run(req, res, env)
// if err != nil {
// t.Logf("Error during file copy: %v", err) // Print actual error
// fmt.Println("Error:", err) // Alternative direct print
// }

// require.Error(t, err, "copying dag-cbor should fail")
// require.Contains(t, err.Error(), "must be a UnixFS node or raw data")
// // return fmt.Errorf("cp: source must be a UnixFS node or raw data")
// }

func TestFilesCp_DagCborNodeFails(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// _, err := coremock.NewMockNode()
// if err != nil {
// t.Fatal(err)
// }

cmdCtx, err := coremock.MockCmdsCtx()
if err != nil {
t.Fatal(err)
}

// env := cmdenv.Environment{
// Node: node,
// CoreAPI: coreapi.NewCoreAPI(node),
// }
node, err := cmdCtx.ConstructNode()
if err != nil {
t.Fatal(err)
}

cborData := []byte{0x80}
cborNode := dag.NewRawNode(cborData)
err = node.DAG.Add(ctx, cborNode)
if err != nil {
t.Fatal(err)
}

cborCID := "bafyreigbtj4x7ip5legnfznufuopl4sg4knzc2cof6duas4b3q2fy6swua"
req := &cmds.Request{
Context: ctx,
Arguments: []string{
"/ipfs/" + cborCID,
"/ipfs/" + cborNode.Cid().String(),
"/test-destination",
},
Options: map[string]interface{}{
Expand All @@ -113,6 +48,7 @@ func TestFilesCp_DagCborNodeFails(t *testing.T) {
if err != nil {
t.Fatal(err)
}

err = filesCpCmd.Run(req, res, &cmdCtx)

if err == nil {
Expand Down