github.com/kvattikuti/drone@v0.2.1-0.20140603034306-d400229a327a/pkg/build/proxy/proxy_test.go (about) 1 package proxy 2 3 import ( 4 "testing" 5 ) 6 7 func TestProxy(t *testing.T) { 8 // test creating a proxy with a few different 9 // addresses, and our ability to create the 10 // proxy shell script. 11 p := Proxy{} 12 p.Set("8080", "172.1.4.5") 13 p.Set("8000", "172.1.3.1") 14 b := p.Bytes() 15 16 expected := `#!/bin/bash 17 [ -x /usr/bin/socat ] && socat TCP-LISTEN:8080,fork TCP:172.1.4.5:8080 & 18 [ -x /usr/bin/socat ] && socat TCP-LISTEN:8000,fork TCP:172.1.3.1:8000 & 19 ` 20 if string(b) != expected { 21 t.Errorf("Invalid proxy \n%s", expected) 22 } 23 24 // test creating a proxy script when there 25 // are no proxy addresses added to the map 26 p = Proxy{} 27 b = p.Bytes() 28 expected = "#!/bin/bash\n" 29 if string(b) != expected { 30 t.Errorf("Invalid proxy \n%s", expected) 31 } 32 }