github
326 of 544 new or added lines in 26 files covered. (59.93%)
1515 existing lines in 52 files now uncovered.10342 of 23192 relevant lines covered (44.59%)
0.47 hits per line
1 |
package data
|
|
2 |
|
|
3 |
import (
|
|
4 |
"context"
|
|
5 |
"testing"
|
|
6 |
|
|
7 |
qt "github.com/frankban/quicktest"
|
|
8 |
ipfscore "github.com/ipfs/kubo/core"
|
|
9 |
ipfsapi "github.com/ipfs/kubo/core/coreapi"
|
|
10 |
"go.vocdoni.io/dvote/db/lru"
|
|
11 |
) |
|
12 |
|
|
13 |
// MockIPFS returns a IPFSHandle with a (offline, nilrepo) IPFS node
|
|
14 |
// with a functional CoreAPI
|
|
UNCOV
15
|
func MockIPFS(t testing.TB) Storage {
|
× |
UNCOV
16
|
storage := IPFSHandle{} |
× |
UNCOV
17
|
n, err := ipfscore.NewNode(context.Background(), &ipfscore.BuildCfg{ |
× |
UNCOV
18
|
Online: false,
|
× |
UNCOV
19
|
Permanent: false,
|
× |
UNCOV
20
|
NilRepo: false,
|
× |
UNCOV
21
|
}) |
× |
UNCOV
22
|
qt.Assert(t, err, qt.IsNil) |
× |
UNCOV
23
|
storage.retrieveCache = lru.New(RetrievedFileCacheSize) |
× |
UNCOV
24
|
storage.Node = n |
× |
UNCOV
25
|
api, err := ipfsapi.NewCoreAPI(n) |
× |
UNCOV
26
|
qt.Assert(t, err, qt.IsNil) |
× |
UNCOV
27
|
storage.CoreAPI = api |
× |
UNCOV
28
|
return &storage
|
× |
UNCOV
29
|
} |
× |