2015-09-27 15:59:51 +02:00
package main
import (
"net/http"
"os/exec"
"time"
2016-04-02 12:40:21 +02:00
"github.com/go-check/check"
2015-09-27 15:59:51 +02:00
checker "github.com/vdemeester/shakers"
)
2016-03-27 16:27:56 +02:00
// File test suites
type FileSuite struct { BaseSuite }
func ( s * FileSuite ) SetUpSuite ( c * check . C ) {
s . createComposeProject ( c , "file" )
2016-04-02 12:40:21 +02:00
s . composeProject . Start ( c )
2016-03-27 16:27:56 +02:00
}
2015-09-27 15:59:51 +02:00
func ( s * FileSuite ) TestSimpleConfiguration ( c * check . C ) {
2016-01-13 22:46:44 +01:00
cmd := exec . Command ( traefikBinary , "--configFile=fixtures/file/simple.toml" )
2015-09-27 15:59:51 +02:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
2015-11-03 23:06:31 +01:00
defer cmd . Process . Kill ( )
2015-09-27 15:59:51 +02:00
2015-11-13 11:50:32 +01:00
time . Sleep ( 1000 * time . Millisecond )
2016-01-13 22:46:44 +01:00
resp , err := http . Get ( "http://127.0.0.1:8000/" )
2015-10-17 14:46:31 +02:00
// Expected a 404 as we did not configure anything
c . Assert ( err , checker . IsNil )
c . Assert ( resp . StatusCode , checker . Equals , 404 )
}
// #56 regression test, make sure it does not fail
func ( s * FileSuite ) TestSimpleConfigurationNoPanic ( c * check . C ) {
2016-01-13 22:46:44 +01:00
cmd := exec . Command ( traefikBinary , "--configFile=fixtures/file/56-simple-panic.toml" )
2015-10-17 14:46:31 +02:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
2015-11-03 23:06:31 +01:00
defer cmd . Process . Kill ( )
2015-10-17 14:46:31 +02:00
2015-11-13 11:50:32 +01:00
time . Sleep ( 1000 * time . Millisecond )
2016-01-13 22:46:44 +01:00
resp , err := http . Get ( "http://127.0.0.1:8000/" )
2015-09-27 15:59:51 +02:00
2015-10-06 21:00:53 +02:00
// Expected a 404 as we did not configure anything
2015-09-27 15:59:51 +02:00
c . Assert ( err , checker . IsNil )
c . Assert ( resp . StatusCode , checker . Equals , 404 )
}