@@ -104,13 +104,14 @@ describe("ReliabilityManager", () => {
104104 } ) ;
105105
106106 describe ( "Known version, reliabilityFactor exceeds reliabilityThreshold" , ( ) => {
107- let trx ;
107+ let trx , trxSpy ;
108108 before ( async ( ) => {
109109 const guid = randomBuffer ( consts . GUID_SIZE ) ;
110110 const hash = randomBuffer ( consts . HASH_SIZE ) ;
111111 await rm . processTransaction ( new StablePutTransaction ( guid , hash ) ) ; // once
112112 await rm . processTransaction ( new StablePutTransaction ( guid , hash ) ) ; // twice
113113 trx = new StablePutTransaction ( guid , hash ) ;
114+ trxSpy = sinon . spy ( trx , "writeFilesToPath" ) ;
114115 assert ( trx . isValid ) ;
115116 await rm . processTransaction ( trx ) ; // three times (last time)
116117 } ) ;
@@ -125,6 +126,10 @@ describe("ReliabilityManager", () => {
125126 it ( "should invalidate the transaction to prevent changes to the version" , ( ) => {
126127 assert ( ! trx . isValid ) ;
127128 } ) ;
129+
130+ it ( "should not tell the cache to write unreliable files" , ( ) => {
131+ assert ( ! trxSpy . called ) ;
132+ } ) ;
128133 } ) ;
129134
130135 describe ( "Known version, inconsistent versionHash" , ( ) => {
@@ -150,10 +155,12 @@ describe("ReliabilityManager", () => {
150155 assert ( ! trx . isValid ) ;
151156 } ) ;
152157
158+ // seperated this into 2 tests
153159 it ( "should tell the transaction to write unreliable files if saveUnreliableVersionArtifacts is true" , async ( ) => {
154160 assert ( spy . called ) ;
161+ } ) ;
155162
156- // Test with saveUnreliableVersionArtifacts = false
163+ it ( "should not tell the transaction to write unreliable files if saveUnreliableVersionArtifacts is false" , async ( ) => {
157164 const myRm = new ReliabilityManager ( db , tmp . tmpNameSync ( ) , { reliabilityThreshold : 2 , saveUnreliableVersionArtifacts : false } ) ;
158165 spy . resetHistory ( ) ;
159166 await myRm . processTransaction ( trx ) ;
0 commit comments