BuildLogFormatUpstream function was always using the default log-format-upstream,
This commit is contained in:
parent
0b48d3b24d
commit
1e5081baf2
3 changed files with 16 additions and 6 deletions
|
|
@ -9,15 +9,18 @@ func TestBuildLogFormatUpstream(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
useProxyProtocol bool // use proxy protocol
|
||||
curLogFormat string
|
||||
expected string
|
||||
}{
|
||||
{true, fmt.Sprintf(logFormatUpstream, "$proxy_protocol_addr")},
|
||||
{false, fmt.Sprintf(logFormatUpstream, "$remote_addr")},
|
||||
{true, "", fmt.Sprintf(logFormatUpstream, "$proxy_protocol_addr")},
|
||||
{false, "", fmt.Sprintf(logFormatUpstream, "$remote_addr")},
|
||||
{true, "my-log-format", "my-log-format"},
|
||||
{false, "john-log-format", "john-log-format"},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
|
||||
result := BuildLogFormatUpstream(testCase.useProxyProtocol)
|
||||
result := BuildLogFormatUpstream(testCase.useProxyProtocol, testCase.curLogFormat)
|
||||
|
||||
if result != testCase.expected {
|
||||
t.Errorf(" expected %v but return %v", testCase.expected, result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue