Merge pull request #443 from chanwit/bats-func-tests

Proposal: PoC for Bats integration tests
This commit is contained in:
Andrea Luzzardi 2015-03-03 16:18:41 -08:00
commit fd8ff48bec
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bats
load vars
@test "managing non-available node should be timed out" {
#
# timeout does not accept a bash function, so hard-coded path is required
#
run timeout 15s $GOBIN/swarm manage -H 127.0.0.1:2375 nodes://8.8.8.8:2375
[ "$status" -ne 0 ]
[[ ${lines[0]} =~ "Listening for HTTP" ]]
[[ ${lines[1]} =~ "ConnectEx tcp: i/o timeout" ]]
}

View File

@ -0,0 +1,5 @@
#!/bin/bash
function swarm() {
$GOBIN/swarm $@
}

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bats
load vars
@test "version string should contain a proper number with git commit" {
run swarm -v
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ version\ [0-9]+\.[0-9]+\.[0-9]+\ \([0-9a-f]{7}\)$ ]]
}