@@ -2,6 +2,7 @@ package cdn
22
33import (
44 "context"
5+ "io/ioutil"
56 "testing"
67 "time"
78
@@ -29,6 +30,9 @@ func TestSyncBuffer(t *testing.T) {
2930 cdntest .ClearItem (t , context .Background (), m , db )
3031 cdntest .ClearUnits (t , context .Background (), m , db )
3132
33+ tmpDir , err := ioutil .TempDir ("" , t .Name ()+ "-cdn-*" )
34+ require .NoError (t , err )
35+
3236 // Create cdn service
3337 s := Service {
3438 DBConnectionFactory : factory ,
@@ -38,10 +42,6 @@ func TestSyncBuffer(t *testing.T) {
3842 GoRoutines : sdk .NewGoRoutines (),
3943 },
4044 }
41- cdsConfig := & storage.CDSStorageConfiguration {
42- Host : "http://lolcat.host:8081" ,
43- Token : "mytoken" ,
44- }
4545 cdnUnits , err := storage .Init (context .Background (), m , cache , db .DbMap , sdk .NewGoRoutines (), storage.Configuration {
4646 HashLocatorSalt : "thisismysalt" ,
4747 Buffers : map [string ]storage.BufferConfiguration {
@@ -55,7 +55,15 @@ func TestSyncBuffer(t *testing.T) {
5555 },
5656 Storages : map [string ]storage.StorageConfiguration {
5757 "test-cds-backend.TestSyncBuffer" : {
58- CDS : cdsConfig ,
58+ CDS : & storage.CDSStorageConfiguration {
59+ Host : "http://lolcat.host:8081" ,
60+ Token : "mytoken" ,
61+ },
62+ },
63+ "test-local.TestSyncBuffer" : {
64+ Local : & storage.LocalStorageConfiguration {
65+ Path : tmpDir ,
66+ },
5967 },
6068 },
6169 })
@@ -92,14 +100,12 @@ func TestSyncLog(t *testing.T) {
92100 },
93101 }
94102
95- cdsConfig := & storage.CDSStorageConfiguration {
96- Host : "http://lolcat.host:8081" ,
97- Token : "mytoken" ,
98- }
99-
100103 ctx , cancel := context .WithTimeout (context .TODO (), 5 * time .Second )
101104 t .Cleanup (cancel )
102105
106+ tmpDir , err := ioutil .TempDir ("" , t .Name ()+ "-cdn-*" )
107+ require .NoError (t , err )
108+
103109 cdnUnits , err := storage .Init (ctx , m , cache , db .DbMap , sdk .NewGoRoutines (), storage.Configuration {
104110 HashLocatorSalt : "thisismysalt" ,
105111 SyncNbElements : 100 ,
@@ -116,7 +122,15 @@ func TestSyncLog(t *testing.T) {
116122 },
117123 Storages : map [string ]storage.StorageConfiguration {
118124 "test-cds-backend.TestSyncLog" : {
119- CDS : cdsConfig ,
125+ CDS : & storage.CDSStorageConfiguration {
126+ Host : "http://lolcat.host:8081" ,
127+ Token : "mytoken" ,
128+ },
129+ },
130+ "test-local.TestSyncLog" : {
131+ Local : & storage.LocalStorageConfiguration {
132+ Path : tmpDir ,
133+ },
120134 },
121135 },
122136 })
0 commit comments