1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/boynux/squid-exporter/config"
)
func TestCreatProxyHelper(t *testing.T) {
// createProxyHeader calls net.LookupIP, which will fail in a build env
if testing.Short() {
t.Skip("skipping testing in short mode")
}
cfg := &config.Config{
ListenAddress: "192.0.2.1:3192",
SquidHostname: "127.0.0.1",
SquidPort: 3128,
}
expectedHProxyString := "PROXY TCP4 192.0.2.1 127.0.0.1 3192 3128"
p := createProxyHeader(cfg)
assert.Equal(t, expectedHProxyString, p, "Proxy headers do not match!")
}
|