From b539d3a4110aef5e5ad0da04d75470b79722217a Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Wed, 30 Mar 2016 12:37:08 -0700 Subject: [PATCH] test: check formatting for all relevant packages in pkg/ --- pkg/adt/interval_tree.go | 2 +- pkg/cors/cors.go | 4 +++- pkg/cors/cors_test.go | 2 +- pkg/schedule/schedule_test.go | 2 +- pkg/testutil/testutil.go | 1 + pkg/types/urlsmap_test.go | 2 +- test | 3 ++- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/adt/interval_tree.go b/pkg/adt/interval_tree.go index 465c6200c..952e95065 100644 --- a/pkg/adt/interval_tree.go +++ b/pkg/adt/interval_tree.go @@ -400,7 +400,7 @@ func (ivt *IntervalTree) MaxHeight() int { return int((2 * math.Log2(float64(ivt.Len()+1))) + 0.5) } -// InternalVisitor is used on tree searchs; return false to stop searching. +// IntervalVisitor is used on tree searchs; return false to stop searching. type IntervalVisitor func(n *IntervalValue) bool // Visit calls a visitor function on every tree node intersecting the given interval. diff --git a/pkg/cors/cors.go b/pkg/cors/cors.go index d149d10a2..4a8c79c92 100644 --- a/pkg/cors/cors.go +++ b/pkg/cors/cors.go @@ -19,12 +19,13 @@ import ( "fmt" "net/http" "net/url" + "sort" "strings" ) type CORSInfo map[string]bool -// CORSInfo implements the flag.Value interface to allow users to define a list of CORS origins +// Set implements the flag.Value interface to allow users to define a list of CORS origins func (ci *CORSInfo) Set(s string) error { m := make(map[string]bool) for _, v := range strings.Split(s, ",") { @@ -49,6 +50,7 @@ func (ci *CORSInfo) String() string { for k := range *ci { o = append(o, k) } + sort.StringSlice(o).Sort() return strings.Join(o, ",") } diff --git a/pkg/cors/cors_test.go b/pkg/cors/cors_test.go index 90b6b8b97..6c39b38d1 100644 --- a/pkg/cors/cors_test.go +++ b/pkg/cors/cors_test.go @@ -91,7 +91,7 @@ func TestCORSHandler(t *testing.T) { return http.Header{ "Access-Control-Allow-Methods": []string{"POST, GET, OPTIONS, PUT, DELETE"}, "Access-Control-Allow-Origin": []string{origin}, - "Access-Control-Allow-Headers": []string{"accept, content-type"}, + "Access-Control-Allow-Headers": []string{"accept, content-type, authorization"}, } } tests := []struct { diff --git a/pkg/schedule/schedule_test.go b/pkg/schedule/schedule_test.go index 7d49f1405..dc2dab193 100644 --- a/pkg/schedule/schedule_test.go +++ b/pkg/schedule/schedule_test.go @@ -28,7 +28,7 @@ func TestFIFOSchedule(t *testing.T) { jobCreator := func(i int) Job { return func(ctx context.Context) { if next != i { - t.Fatalf("job#%d: got %d, want %d", next, i) + t.Fatalf("job#%d: got %d, want %d", i, next, i) } next = i + 1 } diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go index 464e5cccf..a789667b5 100644 --- a/pkg/testutil/testutil.go +++ b/pkg/testutil/testutil.go @@ -22,6 +22,7 @@ import ( "time" ) +// WaitSchedule briefly sleeps in order to invoke the go scheduler. // TODO: improve this when we are able to know the schedule or status of target go-routine. func WaitSchedule() { time.Sleep(10 * time.Millisecond) diff --git a/pkg/types/urlsmap_test.go b/pkg/types/urlsmap_test.go index e2ba6a5cd..5205cdeb0 100644 --- a/pkg/types/urlsmap_test.go +++ b/pkg/types/urlsmap_test.go @@ -98,7 +98,7 @@ func TestParse(t *testing.T) { } } -// This is only tested in Go1.5+ because Go1.4 doesn't support literal IPv6 address with zone in +// TestNewURLsMapIPV6 is only tested in Go1.5+ because Go1.4 doesn't support literal IPv6 address with zone in // URI (https://github.com/golang/go/issues/6530). func TestNewURLsMapIPV6(t *testing.T) { c, err := NewURLsMap("mem1=http://[2001:db8::1]:2380,mem1=http://[fe80::6e40:8ff:feb1:58e4%25en0]:2380,mem2=http://[fe80::92e2:baff:fe7c:3224%25ext0]:2380") diff --git a/test b/test index 208523d28..63cd7a8a7 100755 --- a/test +++ b/test @@ -17,7 +17,8 @@ GO_BUILD_FLAGS=-a source ./build # Hack: gofmt ./ will recursively check the .git directory. So use *.go for gofmt. -TESTABLE_AND_FORMATTABLE="client clientv3 discovery error etcdctl/ctlv2 etcdctl/ctlv3 etcdmain etcdserver etcdserver/auth etcdserver/etcdhttp etcdserver/etcdhttp/httptypes pkg/fileutil pkg/flags pkg/idutil pkg/ioutil pkg/netutil pkg/osutil pkg/pbutil pkg/types pkg/transport pkg/wait proxy raft snap storage storage/backend store version wal" +PKGS=`ls pkg/*/*go | cut -f1,2 -d/ | sort | uniq` +TESTABLE_AND_FORMATTABLE="client clientv3 discovery error etcdctl/ctlv2 etcdctl/ctlv3 etcdmain etcdserver etcdserver/auth etcdserver/etcdhttp etcdserver/etcdhttp/httptypes $PKGS proxy raft snap storage storage/backend store version wal" # TODO: add it to race testing when the issue is resolved # https://github.com/golang/go/issues/9946 NO_RACE_TESTABLE="rafthttp"