HTTP load generator, ApacheBench (ab) replacement
Go
various readability improvements
Jaana Burcu Dogan55673919c297
diff --git a/hey.go b/hey.goindex 8d7da22..e607838 100644--- a/hey.go+++ b/hey.go@@ -52,8 +52,7 @@ var (q = flag.Int("q", 0, "")t = flag.Int("t", 20, "")- h2 = flag.Bool("h2", false, "")-+ h2 = flag.Bool("h2", false, "")cpus = flag.Int("cpus", runtime.GOMAXPROCS(-1), "")disableCompression = flag.Bool("disable-compression", false, "")diff --git a/hey_test.go b/hey_test.goindex 3c101c7..97a6b5b 100644--- a/hey_test.go+++ b/hey_test.go@@ -21,40 +21,46 @@ import (func TestParseValidHeaderFlag(t *testing.T) {match, err := parseInputWithRegexp("X-Something: !Y10K:;(He@poverflow?)", headerRegexp)if err != nil {- t.Errorf("A valid header was not parsed correctly: %v", err.Error())+ t.Errorf("parseInputWithRegexp errored: %v", err)}- if match[1] != "X-Something" || match[2] != "!Y10K:;(He@poverflow?)" {- t.Errorf("A valid header was not parsed correctly, parsed values: %v %v", match[1], match[2])+ if got, want := match[1], "X-Something"; got != want {+ t.Errorf("got %v; want %v", got, want)+ }+ if got, want := match[2], "!Y10K:;(He@poverflow?)"; got != want {+ t.Errorf("got %v; want %v", got, want)}}func TestParseInvalidHeaderFlag(t *testing.T) {_, err := parseInputWithRegexp("X|oh|bad-input: badbadbad", headerRegexp)if err == nil {- t.Errorf("An invalid header passed parsing")+ t.Errorf("Header parsing errored; want no errors")}}func TestParseValidAuthFlag(t *testing.T) {match, err := parseInputWithRegexp("_coo-kie_:!!bigmonster@1969sid", authRegexp)if err != nil {- t.Errorf("A valid auth flag was not parsed correctly: %v", err.Error())+ t.Errorf("A valid auth flag was not parsed correctly: %v", err)+ }+ if got, want := match[1], "_coo-kie_"; got != want {+ t.Errorf("got %v; want %v", got, want)}- if match[1] != "_coo-kie_" || match[2] != "!!bigmonster@1969sid" {- t.Errorf("A valid auth flag was not parsed correctly, parsed values: %v %v", match[1], match[2])+ if got, want := match[2], "!!bigmonster@1969sid"; got != want {+ t.Errorf("got %v; want %v", got, want)}}func TestParseInvalidAuthFlag(t *testing.T) {_, err := parseInputWithRegexp("X|oh|bad-input: badbadbad", authRegexp)if err == nil {- t.Errorf("An invalid header passed parsing")+ t.Errorf("Header parsing errored; want no errors")}}func TestParseAuthMetaCharacters(t *testing.T) {_, err := parseInputWithRegexp("plus+$*{:boom", authRegexp)if err != nil {- t.Errorf("Could not parse an auth header with a plus sign in the user name")+ t.Errorf("Auth header with a plus sign in the user name errored: %v", err)}}