woodpecker/shared/build/proxy/proxy_test.go

30 lines
700 B
Go
Raw Normal View History

2014-02-07 10:10:01 +00:00
package proxy
import (
"testing"
)
func TestProxy(t *testing.T) {
// test creating a proxy with a few different
// addresses, and our ability to create the
// proxy shell script.
p := Proxy{}
p.Set("8080", "172.1.4.5")
b := p.Bytes()
2015-02-07 06:38:08 +00:00
expected := header + `[ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 &
[ -x /tmp/socat ] && /tmp/socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 &
2014-02-07 10:10:01 +00:00
`
if string(b) != expected {
2015-02-07 07:29:50 +00:00
t.Errorf("Invalid proxy \n%s", string(b))
2014-02-07 10:10:01 +00:00
}
// test creating a proxy script when there
// are no proxy addresses added to the map
p = Proxy{}
b = p.Bytes()
2015-02-07 06:38:08 +00:00
if string(b) != header {
t.Errorf("Invalid empty proxy file. Expected\n%s", header)
2014-02-07 10:10:01 +00:00
}
}