Last active
September 24, 2023 22:04
-
-
Save scripting/831fbb4cd8df63debdcb3bca03d4e716 to your computer and use it in GitHub Desktop.
The test FeedLand runs to be sure static memory is working by calling the server to set and get a JSON file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testUserDatafiles (ctsecs=0) { //9/19/23 by DW | |
function oneTest (callback) { | |
const fname = "test.json", whenstart = new Date (); | |
var theTestData = { | |
theArray: new Array () | |
} | |
for (var i = 1; i <= 15; i++) { | |
theTestData.theArray.push (getRandomSnarkySlogan ()); | |
} | |
uploadUserDataFile (fname, jsonStringify (theTestData), "application/json", true, function (err, data) { | |
if (err) { | |
console.log ("testUserDatafiles: err.message == " + err.message); | |
callback (false); | |
} | |
else { | |
setTimeout (function () { | |
getUserDataFile (fname, true, true, function (err, data) { | |
if (err) { | |
console.log ("testUserDatafiles: err.message == " + err.message); | |
callback (false); | |
} | |
else { | |
let savedTestdata, flGoodSave = true; | |
try { | |
savedTestdata = JSON.parse (data.filedata); | |
} | |
catch (err) { | |
console.log ("testUserDatafiles: err.message == " + err.message); | |
flGoodSave = false; | |
} | |
for (var i = 0; i <= 14; i++) { | |
if (savedTestdata.theArray [i] != theTestData.theArray [i]) { | |
console.log ("testUserDatafiles: the data doesn't match. i == " + i + ", original data == " + theTestData.theArray [i] + ", what we got back == " + savedTestdata.theArray [i]); | |
flGoodSave = false; | |
break; | |
} | |
} | |
callback (flGoodSave); | |
} | |
}); | |
}, ctsecs * 1000); | |
} | |
}); | |
} | |
console.log ("testUserDatafiles"); | |
oneTest (function (flworked) { | |
if (flworked) { | |
oneTest (function (flworked) { | |
if (flworked) { | |
console.log ("testUserDatafiles: everything checks out."); | |
} | |
}); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment