-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
330 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.k6.io/k6/cmd/tests" | ||
"go.k6.io/k6/lib/testutils/httpmultibin" | ||
) | ||
|
||
// SetOutput sets the global log so it is racy with other tests | ||
// | ||
//nolint:paralleltest | ||
func TestStdLogOutputIsSet(t *testing.T) { | ||
tb := httpmultibin.NewHTTPMultiBin(t) | ||
ts := tests.NewGlobalTestState(t) | ||
// Sometimes the Go runtime uses the standard log output to | ||
// log some messages directly. | ||
// It does when an invalid char is found in a Cookie. | ||
// Check for details https://github.com/grafana/k6/issues/711#issue-341414887 | ||
ts.Stdin = bytes.NewReader([]byte(tb.Replacer.Replace(` | ||
import http from 'k6/http'; | ||
export const options = { | ||
hosts: { | ||
"HTTPSBIN_DOMAIN": "HTTPSBIN_IP", | ||
}, | ||
insecureSkipTLSVerify: true, | ||
} | ||
export default function() { | ||
http.get("HTTPSBIN_URL/get", { | ||
"cookies": { | ||
"test": "\"" | ||
}, | ||
}) | ||
}`))) | ||
|
||
ts.CmdArgs = []string{"k6", "run", "-i", "1", "-"} | ||
newRootCommand(ts.GlobalState).execute() | ||
|
||
entries := ts.LoggerHook.Drain() | ||
require.Len(t, entries, 1) | ||
assert.Contains(t, entries[0].Message, "Cookie.Value; dropping invalid bytes") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.