n0-computer / beetle

Other
34 stars 15 forks source link

Add tests for unixfs_builder::add_file and add_dir #152

Open rklaehn opened 2 years ago

rklaehn commented 2 years ago

Since these operations read from the file system, you would have to create a temp directory, write some files, then call these ops with a dummy store and check that the data is correctly added.

It would test the actual directory traversal as well as the code that calls store.put with the blocks generated from the file or directory builder.

This would be a bit more like an integration test than an unit test.

rklaehn commented 1 year ago

@faassen I guess the work you did with the iroh api should simplify this... Can we close it already? Not sure how much the trycmd test already cover.

faassen commented 1 year ago

The trycmd tests exercise only the CLI and API, not the actual resolver interaction as that's mocked away.

The tempdir crate is useful if you need to set up some test data in a dir and guarantee it gets removed when it goes out of scope.