summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2017-11-10 23:12:50 +0100
committerRicardo Wurmus <rekado@elephly.net>2017-11-10 23:12:50 +0100
commit50b64124497b33c64e530bb5750e1b4057bfdf51 (patch)
treea1e4ca6f6ca073ba69db95e30224db44777e9167 /tests
parent7ad934f377fd9c81133ddd9e3b09cdb61e21a4eb (diff)
Add tests.
* Makefile.am (TEST_EXTENSIONS, SCM_TESTS, TESTS, SCM_LOG_DRIVER, AM_SCM_LOG_DRIVER_FLAGS): New variables. * build-aux/install-sh, build-aux/missing, build-aux/test-driver.scm, tests/operations.scm, tests/requests/newest-bugs.xml tests/responses/newest-bugs1.xml: New files.
Diffstat (limited to 'tests')
-rw-r--r--tests/operations.scm47
-rw-r--r--tests/requests/newest-bugs.xml1
-rw-r--r--tests/responses/newest-bugs1.xml16
3 files changed, 64 insertions, 0 deletions
diff --git a/tests/operations.scm b/tests/operations.scm
new file mode 100644
index 0000000..c15bf1b
--- /dev/null
+++ b/tests/operations.scm
@@ -0,0 +1,47 @@
+;;; Guile-Debbugs --- Guile bindings for Debbugs
+;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;;
+;;; This file is part of Guile-Debbugs.
+;;;
+;;; Guile-Debbugs is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-Debbugs is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Guile-Debbugs. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (test-operations)
+ #:use-module (debbugs operations)
+ #:use-module (debbugs soap)
+ #:use-module (srfi srfi-64)
+ #:use-module (ice-9 rdelim)
+ #:use-module (sxml simple))
+
+(test-begin "operations")
+
+(define (asset name)
+ (with-input-from-file (string-append (getenv "srcdir")
+ "/tests/" name)
+ read-string))
+
+(test-assert "newest-bugs generates soap request"
+ (soap-request? (newest-bugs 2)))
+
+(test-equal "newest-bugs generates XML"
+ (string-trim-both (asset "requests/newest-bugs.xml"))
+ (let ((op (newest-bugs 2)))
+ (with-output-to-string
+ (lambda _ (sxml->xml (soap-request-body op))))))
+
+(test-equal "newest-bugs parses response"
+ ((soap-request-callback (newest-bugs 3))
+ (xml->sxml (asset "responses/newest-bugs1.xml")))
+ (list 881351 881352 881353))
+
+(test-end "operations")
diff --git a/tests/requests/newest-bugs.xml b/tests/requests/newest-bugs.xml
new file mode 100644
index 0000000..5815f7c
--- /dev/null
+++ b/tests/requests/newest-bugs.xml
@@ -0,0 +1 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" soapenc:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body><ns1:newest_bugs xmlns:ns1="urn:Debbugs/SOAP" soapenc:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><amount xsi:type="xsd:int">2</amount></ns1:newest_bugs></soap:Body></soap:Envelope>
diff --git a/tests/responses/newest-bugs1.xml b/tests/responses/newest-bugs1.xml
new file mode 100644
index 0000000..399f6da
--- /dev/null
+++ b/tests/responses/newest-bugs1.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+ xmlns:xsd="http://www.w3.org/1999/XMLSchema"
+ xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
+ <soap:Body>
+ <newest_bugsResponse xmlns="urn:Debbugs/SOAP">
+ <soapenc:Array soapenc:arrayType="xsd:int[3]" xsi:type="soapenc:Array">
+ <item xsi:type="xsd:int">881351</item>
+ <item xsi:type="xsd:int">881352</item>
+ <item xsi:type="xsd:int">881353</item>
+ </soapenc:Array>
+ </newest_bugsResponse>
+ </soap:Body>
+</soap:Envelope>