Create Container tested

This commit is contained in:
Luis Fernando Molina committed 2018-07-02 13:45:29 +02:00
1 parent 31a22bec3f
commit 27bc8ac267
3 files changed
+46 -15

No files matched your search

+15 -5
View File
@@ -1,8 +1,5 @@
exports.newTeamSetup = function newTeamSetup() {
CONSOLE_LOG = true;
LOG_FILE_CONTENT = false;
let thisObject = {
newTeam: newTeam,
initialize: initialize
@@ -61,11 +58,24 @@
console.log("[ERROR] TeamSetup -> newTeam -> createContainer -> onContainerCreated -> Could not create the container. ");
console.log("[ERROR] TeamSetup -> newTeam -> createContainer -> onContainerCreated -> err.message = " + err.message);
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
if (err.message === "ContainerAlreadyExists") {
let err = {
resutl: global.CUSTOM_FAIL_RESPONSE.result,
message: "Team Name already taken"
};
callBackFunction(err);
} else {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
}
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
addToEcosystem();
}
}
+30 -10
View File
@@ -87,9 +87,9 @@
if (err !== null || text === null) {
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Error Received from Storage Library. "); }
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> err = " + JSON.stringify(err)); }
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Returning an empty JSON object string. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> err = " + JSON.stringify(err)); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> readData -> onFileReceived -> Returning an empty JSON object string. "); }
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
@@ -157,8 +157,8 @@
if (err !== null || text === null) {
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> Error Received from Storage Library. "); }
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> writeData -> onFileCreated -> err = " + JSON.stringify(err)); }
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
@@ -180,7 +180,7 @@
}
function createContainer(pContainerName, pPath, pFile, pFileContent, callBackFunction) {
function createContainer(pContainerName, callBackFunction) {
try {
@@ -207,22 +207,42 @@
let blobService = storage.createBlobService(connectionString);
pContainerName.toLowerCase();
let containerName = pContainerName.toLowerCase();
blobService.createContainer(pContainerName, onContainerCreated);
blobService.createContainer(containerName, onContainerCreated);
function onContainerCreated(err) {
if (err) {
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> Error Received from Storage Library. "); }
if (CONSOLE_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> err = " + JSON.stringify(err)); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> Error Received from Storage Library. "); }
if (CONSOLE_ERROR_LOG === true) { console.log("[ERROR] Storage -> createContainer -> onContainerCreated -> err = " + JSON.stringify(err)); }
/* ContainerAlreadyExists check */
if (JSON.stringify(err).indexOf("ContainerAlreadyExists") > 0) {
let err = {
resutl: global.CUSTOM_FAIL_RESPONSE.result,
message: "ContainerAlreadyExists"
};
callBackFunction(err);
return;
} else {
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
return;
}
callBackFunction(global.DEFAULT_OK_RESPONSE);
return;
}
} catch (err) {
+1
View File
@@ -1,6 +1,7 @@
/* These 2 are global variables, that is why they do not have a let or var */
CONSOLE_LOG = true;
CONSOLE_ERROR_LOG = true;
LOG_FILE_CONTENT = false;
if (CONSOLE_LOG === true) { console.log("[INFO] server -> Node Server Starting."); }