shlist

share and manage lists between multiple people
Log | Files | Refs

commit 330ada09843341aeef88aa8bc54d1748550a6027
parent 293a7715e6b2188161388255982a8bd261bce4a7
Author: kyle <kyle@0x30.net>
Date:   Tue, 12 Jan 2016 23:45:22 -0700

tests: shuffle code and add test cases

- get mc/dc coverage by explicitly testing all of the cases

Diffstat:
Mserver/tests/device_add/server.log.good | 4+++-
Mserver/tests/device_add/test.pl | 21++++++++++++---------
2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/server/tests/device_add/server.log.good b/server/tests/device_add/server.log.good @@ -1,7 +1,9 @@ new connection (pid = <digits>) ssl ok, ver = 'TLSv1_2' cipher = 'ECDHE-RSA-AES128-SHA256' device_add: success, <digits>:<base64> os <base64> -device_add: phone number '403867530&' invalid device_add: phone number <digits> already exists +device_add: phone number '403867530&' invalid device_add: unknown operating system <base64> +device_add: success, <digits>:<base64> os <base64> +device_add: success, <digits>:<base64> os <base64> disconnected! diff --git a/server/tests/device_add/test.pl b/server/tests/device_add/test.pl @@ -1,26 +1,29 @@ #!/usr/bin/perl -I../ use strict; use warnings; - use client; use test; -# basic sanity check on the device_add message type my $A = client->new(); -my $phnum = $A->phnum; + +# Constructor automatically calls device_add so no need to do it here my $devid = $A->device_id(); my $length = length($devid); fail "device id '$devid' not base64" unless ($devid =~ m/^[a-zA-Z0-9+\/=]+$/); fail "expected device id length of 43, got $length" if ($length != 43); -# try adding a device with a bad phone number +# Duplicate phone number +$A->device_add($A->phnum, 'unix', 'err'); +fail_msg_ne 'the sent phone number already exists', $A->get_error(); + +# Bad phone number $A->device_add('403867530&', 'unix', 'err'); fail_msg_ne 'the sent phone number is not a number', $A->get_error(); -# try adding the same phone number again -$A->device_add($phnum, 'unix', 'err'); -fail_msg_ne 'the sent phone number already exists', $A->get_error(); - -# send device_add with a bad operating system type +# Bad operating system $A->device_add(rand_phnum(), 'bados', 'err'); fail_msg_ne 'operating system not supported', $A->get_error(); + +# Good operating systems +$A->device_add(rand_phnum(), 'android'); +$A->device_add(rand_phnum(), 'ios');