-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-script.lua
More file actions
87 lines (67 loc) · 2.2 KB
/
test-script.lua
File metadata and controls
87 lines (67 loc) · 2.2 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
-- test-script.lua
-- A simple test script for AO that sends API requests
print("Starting Message Bridge Test...")
-- Function to send an email request
function sendEmailRequest()
print("\n----- Sending Email Request -----")
local emailData = {
to = "test@example.com",
subject = "Test Email from AO",
body = "This is a test email sent from AO using the Message Bridge.",
from = "ao@example.com"
}
print("Sending email to: " .. emailData.to)
print("Subject: " .. emailData.subject)
local result = Send({
Target = "self",
Action = "SendEmail",
Data = Utils.toJson(emailData)
})
print("Email request sent")
return result
end
-- Function to create a document
function createDocumentRequest()
print("\n----- Creating Document Request -----")
local documentData = {
fileName = "Test Document.pdf",
fileSize = 1024,
contentType = "application/pdf",
uploadedBy = "test@example.com",
department = "Testing",
content = "This is a test document created from AO using the Message Bridge."
}
print("Creating document: " .. documentData.fileName)
local result = Send({
Target = "self",
Action = "CreateDocument",
Data = Utils.toJson(documentData)
})
print("Document creation request sent")
return result
end
-- Function to list documents
function listDocumentsRequest()
print("\n----- Listing Documents Request -----")
local result = Send({
Target = "self",
Action = "ListDocuments",
Data = Utils.toJson({})
})
print("List documents request sent")
return result
end
-- Run the test
print("\nRunning Message Bridge Test...")
-- Send an email request
local emailResult = sendEmailRequest()
print("Email request result: " .. Utils.toJson(emailResult))
-- Create a document
local documentResult = createDocumentRequest()
print("Document creation result: " .. Utils.toJson(documentResult))
-- List documents
local listResult = listDocumentsRequest()
print("List documents result: " .. Utils.toJson(listResult))
print("\nTest completed. Check the Message Bridge logs for request processing.")
print("The Message Bridge should detect these requests and process them.")
return "Message Bridge Test completed"