forked from PlayFab/SdkTestingCloudScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExampleCloudScript.js
63 lines (63 loc) · 2.37 KB
/
ExampleCloudScript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
///////////////////////////////////////////////
// JenkinsConsoleUtility CloudScript functions
///////////////////////////////////////////////
var TEST_TITLE_ID = "6195"; // NOTE: Replace this with your own titleID - DeleteUsers has an additional security check to avoid accidents
var TEST_DATA_KEY = "TEST_DATA_KEY"; // Used to reuse args.customId, but it was kindof a pain, and made things fragile
handlers.helloWorld = function (args, context) {
var message = "Hello " + currentPlayerId + "!";
log.info(message);
var inputValue = null;
if (args && args.hasOwnProperty("inputValue"))
inputValue = args.inputValue;
log.debug("helloWorld:", { input: inputValue });
return { messageValue: message };
};
handlers.throwError = function (args) {
var testObject = undefined;
var failureObj = testObject.doesnotexist.doesnotexist;
return failureObj; // Can't get to here
};
handlers.easyLogEvent = function (args) {
log.info(JSON.stringify(args.logMessage));
};
///////////////////////////////////////////////
// JenkinsConsoleUtility CloudScript functions
///////////////////////////////////////////////
handlers.TestDataExists = function (args) {
var playerData = server.GetUserInternalData({
PlayFabId: currentPlayerId,
Keys: [TEST_DATA_KEY]
});
return playerData.Data.hasOwnProperty(TEST_DATA_KEY);
};
handlers.GetTestData = function (args) {
var testResults = null;
var playerData = server.GetUserInternalData({
PlayFabId: currentPlayerId,
Keys: [TEST_DATA_KEY]
});
if (playerData.Data.hasOwnProperty(TEST_DATA_KEY)) {
log.info("Returning Data: " + playerData.Data[TEST_DATA_KEY].Value);
testResults = JSON.parse(playerData.Data[TEST_DATA_KEY].Value);
var data = {};
data[TEST_DATA_KEY] = null;
server.UpdateUserInternalData({
PlayFabId: currentPlayerId,
Data: data
});
}
else {
log.info("Expected data not found in: " + JSON.stringify(playerData));
}
return testResults;
};
handlers.SaveTestData = function (args) {
var data = {};
data[TEST_DATA_KEY] = JSON.stringify(args.testReport);
log.info("Saving Data (" + currentPlayerId + "): " + JSON.stringify(data));
server.UpdateUserInternalData({
PlayFabId: currentPlayerId,
Data: data
});
};
//# sourceMappingURL=ExampleCloudScript.js.map