-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test.go
More file actions
46 lines (42 loc) · 953 Bytes
/
api_test.go
File metadata and controls
46 lines (42 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package seed_test
import (
"context"
"os"
"testing"
files "github.com/ipfs/go-ipfs-files"
httpapi "github.com/ipfs/go-ipfs-http-client"
"github.com/ipfs/interface-go-ipfs-core/options"
"github.com/multiformats/go-multiaddr"
)
// TestApiCall_Call ...
func TestApiAdd(t *testing.T) {
var api *httpapi.HttpApi
addr, e := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/5001")
if e != nil {
t.Error(e)
return
}
api, e = httpapi.NewApi(addr)
if e != nil {
t.Error(e)
return
}
file, e := os.Open("d:\\video\\temp\\9df762a1-b1ae-478f-82c6-462d7b3a2286\\")
if e != nil {
t.Error(e)
return
}
np, e := files.NewReaderPathFile("d:\\video\\temp\\9df762a1-b1ae-478f-82c6-462d7b3a2286\\", file, nil)
if e != nil {
t.Error(e)
return
}
resolved, e := api.Unixfs().Add(context.Background(), np, func(settings *options.UnixfsAddSettings) error {
settings.Pin = true
return nil
})
if e != nil {
t.Error(e)
}
t.Log(resolved)
}