File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 88 "os"
99 "path"
1010
11- "github.com/ipfs/go-ipfs-files"
11+ files "github.com/ipfs/go-ipfs-files"
1212)
1313
1414type object struct {
@@ -45,6 +45,14 @@ func RawLeaves(enabled bool) AddOpts {
4545 }
4646}
4747
48+ // Hash allows for selecting the multihash type
49+ func Hash (hash string ) AddOpts {
50+ return func (rb * RequestBuilder ) error {
51+ rb .Option ("hash" , hash )
52+ return nil
53+ }
54+ }
55+
4856func (s * Shell ) Add (r io.Reader , options ... AddOpts ) (string , error ) {
4957 fr := files .NewReaderFile (r )
5058 slf := files .NewSliceDirectory ([]files.DirEntry {files .FileEntry ("" , fr )})
Original file line number Diff line number Diff line change 88func Test_Logger (t * testing.T ) {
99 ctx , cancel := context .WithCancel (context .Background ())
1010 defer cancel ()
11- sh := NewLocalShell ( )
11+ sh := NewShell ( shellUrl )
1212 logger , err := sh .GetLogs (ctx )
1313 if err != nil {
1414 t .Fatal (err )
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ func TestAdd(t *testing.T) {
2828 mhash , err := s .Add (bytes .NewBufferString ("Hello IPFS Shell tests" ))
2929 is .Nil (err )
3030 is .Equal (mhash , "QmUfZ9rAdhV5ioBzXKdUTh2ZNsz9bzbkaLVyQ8uc8pj21F" )
31+ mhash , err = s .Add (bytes .NewBufferString ("Hello IPFS Shell tests" ), Hash ("sha3-256" ))
32+ is .Nil (err )
33+ is .Equal (mhash , "zb2wwqxjxosf8GKEZCwAWSFZ879XFNca3De5yAoh5b2axAffc" )
3134}
3235
3336func TestRedirect (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments