Add Runtime#getNumberOfCloudVariables
This commit is contained in:
1 parent
bfc0960553
commit
f8ec0084ad
2 files changed
+34
-1
No files matched your search
+13
-1
@@ -122,6 +122,8 @@ const ArgumentTypeMap = (() => {
|
||||
* removing an existing cloud variable.
|
||||
* @property {function} hasCloudVariables A function to call to check that
|
||||
* the runtime has any cloud variables.
|
||||
* @property {function} getNumberOfCloudVariables A function that returns the
|
||||
* number of cloud variables in the project.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -151,11 +153,14 @@ const cloudDataManager = cloudOptions => {
|
||||
|
||||
const hasCloudVariables = () => count > 0;
|
||||
|
||||
const getNumberOfCloudVariables = () => count;
|
||||
|
||||
return {
|
||||
canAddCloudVariable,
|
||||
addCloudVariable,
|
||||
removeCloudVariable,
|
||||
hasCloudVariables
|
||||
hasCloudVariables,
|
||||
getNumberOfCloudVariables
|
||||
};
|
||||
};
|
||||
|
||||
@@ -381,6 +386,12 @@ class Runtime extends EventEmitter {
|
||||
*/
|
||||
this.canAddCloudVariable = newCloudDataManager.canAddCloudVariable;
|
||||
|
||||
/**
|
||||
* A function which returns the number of cloud variables in the runtime.
|
||||
* @returns {number}
|
||||
*/
|
||||
this.getNumberOfCloudVariables = newCloudDataManager.getNumberOfCloudVariables;
|
||||
|
||||
/**
|
||||
* A function that tracks a new cloud variable in the runtime,
|
||||
* updating the cloud variable limit. Calling this function will
|
||||
@@ -2028,6 +2039,7 @@ class Runtime extends EventEmitter {
|
||||
const newCloudDataManager = cloudDataManager(this.cloudOptions);
|
||||
this.hasCloudData = newCloudDataManager.hasCloudVariables;
|
||||
this.canAddCloudVariable = newCloudDataManager.canAddCloudVariable;
|
||||
this.getNumberOfCloudVariables = newCloudDataManager.getNumberOfCloudVariables;
|
||||
this.addCloudVariable = this._initializeAddCloudVariable(newCloudDataManager);
|
||||
this.removeCloudVariable = this._initializeRemoveCloudVariable(newCloudDataManager);
|
||||
}
|
||||
|
||||
@@ -192,3 +192,24 @@ test('setStageSize argument range', t => {
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('getNumberOfCloudVariables', t => {
|
||||
const rt = new Runtime();
|
||||
|
||||
t.equal(rt.getNumberOfCloudVariables(), 0);
|
||||
rt.addCloudVariable();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 1);
|
||||
rt.addCloudVariable();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 2);
|
||||
rt.removeCloudVariable();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 1);
|
||||
rt.removeCloudVariable();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 0);
|
||||
|
||||
rt.dispose();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 0);
|
||||
rt.addCloudVariable();
|
||||
t.equal(rt.getNumberOfCloudVariables(), 1);
|
||||
|
||||
t.end();
|
||||
});
|
||||
Reference in new issue
Block a user