@@ -11,66 +11,66 @@ chai.use(dirtyChai)
11
11
module . exports = ( common ) => {
12
12
describe ( '.config' , function ( ) {
13
13
this . timeout ( 30 * 1000 )
14
- let ipfs
14
+ let ipfsd
15
15
16
16
before ( function ( done ) {
17
17
// CI takes longer to instantiate the daemon, so we need to increase the
18
18
// timeout for the before step
19
19
this . timeout ( 60 * 1000 )
20
20
21
- common . setup ( ( err , factory ) => {
21
+ common . setup ( ( err , df ) => {
22
22
expect ( err ) . to . not . exist ( )
23
- factory . spawnNode ( ( err , node ) => {
23
+ df . spawn ( ( err , node ) => {
24
24
expect ( err ) . to . not . exist ( )
25
- ipfs = node
25
+ ipfsd = node
26
26
done ( )
27
27
} )
28
28
} )
29
29
} )
30
30
31
- after ( ( done ) => common . teardown ( done ) )
31
+ after ( ( done ) => ipfsd . stop ( done ) )
32
32
33
33
describe ( '.get' , ( ) => {
34
34
it ( 'retrieve the whole config' , ( done ) => {
35
- ipfs . config . get ( ( err , config ) => {
35
+ ipfsd . api . config . get ( ( err , config ) => {
36
36
expect ( err ) . to . not . exist ( )
37
37
expect ( config ) . to . exist ( )
38
38
done ( )
39
39
} )
40
40
} )
41
41
42
42
it ( 'retrieve a value through a key' , ( done ) => {
43
- ipfs . config . get ( 'Identity.PeerID' , ( err , peerId ) => {
43
+ ipfsd . api . config . get ( 'Identity.PeerID' , ( err , peerId ) => {
44
44
expect ( err ) . to . not . exist ( )
45
45
expect ( peerId ) . to . exist ( )
46
46
done ( )
47
47
} )
48
48
} )
49
49
50
50
it ( 'retrieve a value through a nested key' , ( done ) => {
51
- ipfs . config . get ( 'Addresses.Swarm' , ( err , swarmAddrs ) => {
51
+ ipfsd . api . config . get ( 'Addresses.Swarm' , ( err , swarmAddrs ) => {
52
52
expect ( err ) . to . not . exist ( )
53
53
expect ( swarmAddrs ) . to . exist ( )
54
54
done ( )
55
55
} )
56
56
} )
57
57
58
58
it ( 'fail on non valid key' , ( done ) => {
59
- ipfs . config . get ( 1234 , ( err , peerId ) => {
59
+ ipfsd . api . config . get ( 1234 , ( err , peerId ) => {
60
60
expect ( err ) . to . exist ( )
61
61
done ( )
62
62
} )
63
63
} )
64
64
65
65
it ( 'fail on non exist()ent key' , ( done ) => {
66
- ipfs . config . get ( 'Bananas' , ( err , peerId ) => {
66
+ ipfsd . api . config . get ( 'Bananas' , ( err , peerId ) => {
67
67
expect ( err ) . to . exist ( )
68
68
done ( )
69
69
} )
70
70
} )
71
71
72
72
it ( 'Promises support' , ( ) => {
73
- return ipfs . config . get ( )
73
+ return ipfsd . api . config . get ( )
74
74
. then ( ( config ) => {
75
75
expect ( config ) . to . exist ( )
76
76
} )
@@ -79,9 +79,9 @@ module.exports = (common) => {
79
79
80
80
describe ( '.set' , ( ) => {
81
81
it ( 'set a new key' , ( done ) => {
82
- ipfs . config . set ( 'Fruit' , 'banana' , ( err ) => {
82
+ ipfsd . api . config . set ( 'Fruit' , 'banana' , ( err ) => {
83
83
expect ( err ) . to . not . exist ( )
84
- ipfs . config . get ( 'Fruit' , ( err , fruit ) => {
84
+ ipfsd . api . config . get ( 'Fruit' , ( err , fruit ) => {
85
85
expect ( err ) . to . not . exist ( )
86
86
expect ( fruit ) . to . equal ( 'banana' )
87
87
done ( )
@@ -90,9 +90,9 @@ module.exports = (common) => {
90
90
} )
91
91
92
92
it ( 'set an already exist()ing key' , ( done ) => {
93
- ipfs . config . set ( 'Fruit' , 'morango' , ( err ) => {
93
+ ipfsd . api . config . set ( 'Fruit' , 'morango' , ( err ) => {
94
94
expect ( err ) . to . not . exist ( )
95
- ipfs . config . get ( 'Fruit' , ( err , fruit ) => {
95
+ ipfsd . api . config . get ( 'Fruit' , ( err , fruit ) => {
96
96
expect ( err ) . to . not . exist ( )
97
97
expect ( fruit ) . to . equal ( 'morango' )
98
98
done ( )
@@ -103,9 +103,9 @@ module.exports = (common) => {
103
103
it ( 'set a JSON object' , ( done ) => {
104
104
const key = 'API.HTTPHeaders.Access-Control-Allow-Origin'
105
105
const val = [ 'http://example.io' ]
106
- ipfs . config . set ( key , val , function ( err ) {
106
+ ipfsd . api . config . set ( key , val , function ( err ) {
107
107
expect ( err ) . to . not . exist ( )
108
- ipfs . config . get ( key , function ( err , result ) {
108
+ ipfsd . api . config . get ( key , function ( err , result ) {
109
109
expect ( err ) . to . not . exist ( )
110
110
expect ( result ) . to . deep . equal ( val )
111
111
done ( )
@@ -114,22 +114,22 @@ module.exports = (common) => {
114
114
} )
115
115
116
116
it ( 'fail on non valid key' , ( done ) => {
117
- ipfs . config . set ( Buffer . from ( 'heeey' ) , '' , ( err ) => {
117
+ ipfsd . api . config . set ( Buffer . from ( 'heeey' ) , '' , ( err ) => {
118
118
expect ( err ) . to . exist ( )
119
119
done ( )
120
120
} )
121
121
} )
122
122
123
123
it ( 'fail on non valid value' , ( done ) => {
124
- ipfs . config . set ( 'Fruit' , Buffer . from ( 'abc' ) , ( err ) => {
124
+ ipfsd . api . config . set ( 'Fruit' , Buffer . from ( 'abc' ) , ( err ) => {
125
125
expect ( err ) . to . exist ( )
126
126
done ( )
127
127
} )
128
128
} )
129
129
130
130
it ( 'Promises support' , ( ) => {
131
- return ipfs . config . set ( 'Fruit' , 'banana' )
132
- . then ( ( ) => ipfs . config . get ( 'Fruit' ) )
131
+ return ipfsd . api . config . set ( 'Fruit' , 'banana' )
132
+ . then ( ( ) => ipfsd . api . config . get ( 'Fruit' ) )
133
133
. then ( ( fruit ) => {
134
134
expect ( fruit ) . to . equal ( 'banana' )
135
135
} )
@@ -145,19 +145,19 @@ module.exports = (common) => {
145
145
}
146
146
147
147
it ( 'replace the whole config' , ( done ) => {
148
- ipfs . config . replace ( config , ( err ) => {
148
+ ipfsd . api . config . replace ( config , ( err ) => {
149
149
expect ( err ) . to . not . exist ( )
150
- ipfs . config . get ( ( err , _config ) => {
150
+ ipfsd . api . config . get ( ( err , _config ) => {
151
151
expect ( err ) . to . not . exist ( )
152
152
expect ( _config ) . to . deep . equal ( config )
153
153
} )
154
154
} )
155
155
} )
156
156
157
157
it ( 'replace to empty config' , ( done ) => {
158
- ipfs . config . replace ( { } , ( err ) => {
158
+ ipfsd . api . config . replace ( { } , ( err ) => {
159
159
expect ( err ) . to . not . exist ( )
160
- ipfs . config . get ( ( err , _config ) => {
160
+ ipfsd . api . config . get ( ( err , _config ) => {
161
161
expect ( err ) . to . not . exist ( )
162
162
expect ( _config ) . to . deep . equal ( config )
163
163
} )
0 commit comments