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 8
8
"os"
9
9
"path"
10
10
11
- "github.com/ipfs/go-ipfs-files"
11
+ files "github.com/ipfs/go-ipfs-files"
12
12
)
13
13
14
14
type object struct {
@@ -45,6 +45,14 @@ func RawLeaves(enabled bool) AddOpts {
45
45
}
46
46
}
47
47
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
+
48
56
func (s * Shell ) Add (r io.Reader , options ... AddOpts ) (string , error ) {
49
57
fr := files .NewReaderFile (r )
50
58
slf := files .NewSliceDirectory ([]files.DirEntry {files .FileEntry ("" , fr )})
Original file line number Diff line number Diff line change 8
8
func Test_Logger (t * testing.T ) {
9
9
ctx , cancel := context .WithCancel (context .Background ())
10
10
defer cancel ()
11
- sh := NewLocalShell ( )
11
+ sh := NewShell ( shellUrl )
12
12
logger , err := sh .GetLogs (ctx )
13
13
if err != nil {
14
14
t .Fatal (err )
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ func TestAdd(t *testing.T) {
28
28
mhash , err := s .Add (bytes .NewBufferString ("Hello IPFS Shell tests" ))
29
29
is .Nil (err )
30
30
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" )
31
34
}
32
35
33
36
func TestRedirect (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments