about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-26 21:59:22 +0100
committerJames Booth <boothj5@gmail.com>2015-05-26 21:59:22 +0100
commitc2fde7c2639f318f8d4839955e7b7e17456e0564 (patch)
treea482ad48c1b3f7ce9dd4de74f8e4122acf8b8af0
parent940f6d5f3cbac82f652bbe74e799800c5c2bd0af (diff)
downloadprofani-tty-c2fde7c2639f318f8d4839955e7b7e17456e0564.tar.gz
Added to stabber/expect test
-rw-r--r--expecttest.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/expecttest.c b/expecttest.c
index 2159ed02..6e54b447 100644
--- a/expecttest.c
+++ b/expecttest.c
@@ -1,4 +1,6 @@
 #include <string.h>
+#include <stdlib.h>
+#include <errno.h>
 #include <assert.h>
 #include <expect.h>
 #include <stabber.h>
@@ -10,10 +12,24 @@
 int main(void)
 {
     stbbr_start(5230);
+    stbbr_for("roster",
+        "<iq id=\"roster\" type=\"result\" to=\"stabber@localhost/profanity\">"
+            "<query xmlns=\"jabber:iq:roster\" ver=\"362\">"
+                "<item jid=\"buddy1@localhost\" subscription=\"both\" name=\"Buddy1\"/>"
+                "<item jid=\"buddy2@localhost\" subscription=\"both\" name=\"Buddy2\"/>"
+            "</query>"
+        "</iq>"
+    );
 
     int res = 0;
-    int fd = exp_spawnl("./profanity");
+    int fd = exp_spawnl("./profanity", NULL);
     FILE *fp = fdopen(fd, "r+");
+
+    if (fp == NULL) {
+        perror(NULL);
+        return 0;
+    }
+
     setbuf(fp, (char *)0);
 
     res = exp_expectl(fd, exp_exact, "Profanity. Type /help for help information.", 10, exp_end);
@@ -28,10 +44,19 @@ int main(void)
     assert(res == 12);
     res = exp_expectl(fd, exp_exact, "stabber@localhost logged in successfully", 13, exp_end);
     assert(res == 13);
+
+    sleep(1);
+    assert(stbbr_verify(
+        "<presence id=\"*\">"
+            "<c hash=\"sha-1\" xmlns=\"http://jabber.org/protocol/caps\" ver=\"*\" node=\"http://www.profanity.im\"/>"
+        "</presence>"
+    ));
+
+    stbbr_send();
     
     write(fd, QUIT_CMD, strlen(QUIT_CMD));
     sleep(1);
-
+    
     printf("\n");
     printf("\n");
     printf("PID: %d\n", exp_pid);