summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-24 21:50:17 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-24 21:50:17 (GMT)
commit5698df1c136ebfbf943139b27732bf271e007875 (patch)
tree86dc522849dde483828d73f0b31c593bb2eb605d /Sluift/client_test.lua
parent90d6b45adf84976d99911feb3fb09b27cb6a8d1e (diff)
downloadswift-contrib-5698df1c136ebfbf943139b27732bf271e007875.zip
swift-contrib-5698df1c136ebfbf943139b27732bf271e007875.tar.bz2
Added Sluift client test script and the necessary infrastructure.
Diffstat (limited to 'Sluift/client_test.lua')
-rw-r--r--Sluift/client_test.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/Sluift/client_test.lua b/Sluift/client_test.lua
new file mode 100644
index 0000000..afb8147
--- /dev/null
+++ b/Sluift/client_test.lua
@@ -0,0 +1,32 @@
+require "sluift"
+
+--sluift.debug = true
+client1_jid = os.getenv("SWIFT_CLIENTTEST_JID") .. "/Client1"
+client2_jid = os.getenv("SWIFT_CLIENTTEST_JID") .. "/Client2"
+password = os.getenv("SWIFT_CLIENTTEST_PASS")
+
+print "Connecting client 1"
+client1 = sluift.connect(client1_jid, password)
+client1:send_presence("I'm here")
+
+print "Connecting client 2"
+client2 = sluift.connect(client2_jid, password)
+client2:send_presence("I'm here")
+
+print "Checking version of client 2 from client 1"
+client2:set_version({name = "Sluift Test", version = "1.0"})
+client2_version = client1:get_version(client2_jid)
+assert(client2_version["name"] == "Sluift Test")
+assert(client2_version["version"] == "1.0")
+
+print "Sending message from client 1 to client 2"
+client1:send_message(client2_jid, "Hello")
+received_message = client2:for_event(function(event)
+ if event["type"] == "message" and event["from"] == client1_jid then
+ return event["body"]
+ end
+ end)
+assert(received_message == "Hello")
+
+client1:disconnect()
+client2:disconnect()