Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix format specifiers in Printf-type functions. #1709

Merged
merged 1 commit into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func TestValidateRestartPolicy(t *testing.T) {
}
for k, policy := range errorCases {
if errs := validateRestartPolicy(&policy); len(errs) == 0 {
t.Errorf("expected failure for %s", k)
t.Errorf("expected failure for %d", k)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/auth/authenticator/tokenfile/tokenfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ token2,user2,uid2
t.Errorf("%d: expected user %#v, got %#v", i, testCase.User, user)
}
if testCase.Ok != ok {
t.Errorf("%d: expected auth %f, got %f", i, testCase.Ok, ok)
t.Errorf("%d: expected auth %v, got %v", i, testCase.Ok, ok)
}
switch {
case err == nil && testCase.Err:
Expand Down
6 changes: 3 additions & 3 deletions pkg/auth/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAuthenticateRequest(t *testing.T) {

<-success
if len(context.requests) > 0 {
t.Errorf("context should have no stored requests", context)
t.Errorf("context should have no stored requests: %v", context)
}
}

Expand All @@ -73,7 +73,7 @@ func TestAuthenticateRequestFailed(t *testing.T) {

<-failed
if len(context.requests) > 0 {
t.Errorf("context should have no stored requests", context)
t.Errorf("context should have no stored requests: %v", context)
}
}

Expand All @@ -97,6 +97,6 @@ func TestAuthenticateRequestError(t *testing.T) {

<-failed
if len(context.requests) > 0 {
t.Errorf("context should have no stored requests", context)
t.Errorf("context should have no stored requests: %v", context)
}
}
2 changes: 1 addition & 1 deletion pkg/client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestIsConfigTransportSecure(t *testing.T) {
for _, testCase := range testCases {
secure := IsConfigTransportSecure(testCase.Config)
if testCase.Secure != secure {
t.Errorf("expected %d for %#v", testCase.Secure, testCase.Config)
t.Errorf("expected %v for %#v", testCase.Secure, testCase.Config)
}
}
}
4 changes: 2 additions & 2 deletions pkg/client/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestBearerAuthRoundTripper(t *testing.T) {
req := &http.Request{}
NewBearerAuthRoundTripper("test", rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("unexpected nil request", rt)
t.Fatalf("unexpected nil request: %v", rt)
}
if rt.Request == req {
t.Fatalf("round tripper should have copied request object: %#v", rt.Request)
Expand All @@ -60,7 +60,7 @@ func TestBasicAuthRoundTripper(t *testing.T) {
req := &http.Request{}
NewBasicAuthRoundTripper("user", "pass", rt).RoundTrip(req)
if rt.Request == nil {
t.Fatalf("unexpected nil request", rt)
t.Fatalf("unexpected nil request: %v", rt)
}
if rt.Request == req {
t.Fatalf("round tripper should have copied request object: %#v", rt.Request)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloudprovider/ovirt/ovirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func TestOVirtCloudXmlParsing(t *testing.T) {
t.Fatalf("Unexpected error listing instances: %s", err3)
}
if len(instances3) > 0 {
t.Fatalf("Unexpected number of instance(s): %i", len(instances3))
t.Fatalf("Unexpected number of instance(s): %d", len(instances3))
}

body4 := strings.NewReader(`
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestOVirtCloudXmlParsing(t *testing.T) {
t.Fatalf("Unexpected error listing instances: %s", err4)
}
if len(instances4) != 2 {
t.Fatalf("Unexpected number of instance(s): %i", len(instances4))
t.Fatalf("Unexpected number of instance(s): %d", len(instances4))
}
if instances4[0] != "host1" || instances4[1] != "host3" {
t.Fatalf("Unexpected instance(s): %s", instances4)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudprovider/vagrant/vagrant.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
return net.ParseIP(minion.IP), nil
}
}
return nil, fmt.Errorf("Unable to find IP address for instance:", instance)
return nil, fmt.Errorf("Unable to find IP address for instance: %s", instance)
}

// saltMinionsByRole filters a list of minions that have a matching role.
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestResolvePortInt(t *testing.T) {
expected := 80
port, err := ResolvePort(util.IntOrString{Kind: util.IntstrInt, IntVal: expected}, &api.Container{})
if port != expected {
t.Errorf("expected: %d, saw: %d", port)
t.Errorf("expected: %d, saw: %d", expected, port)
}
if err != nil {
t.Errorf("unexpected error: %v", err)
Expand All @@ -44,7 +44,7 @@ func TestResolvePortString(t *testing.T) {
}
port, err := ResolvePort(util.IntOrString{Kind: util.IntstrString, StrVal: name}, container)
if port != expected {
t.Errorf("expected: %d, saw: %d", port)
t.Errorf("expected: %d, saw: %d", expected, port)
}
if err != nil {
t.Errorf("unexpected error: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/labels/selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ func TestRequiresExactMatch(t *testing.T) {
for k, v := range testCases {
value, found := v.S.RequiresExactMatch(v.Label)
if value != v.Value {
t.Errorf("%s: expected value %s, got %s", k, v.Value, value)
t.Errorf("%s: expected value %v, got %s", k, v.Value, value)
}
if found != v.Found {
t.Errorf("%s: expected found %s, got %s", k, v.Found, found)
t.Errorf("%s: expected found %v, got %s", k, v.Found, found)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/service/ip_allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestIPSub(t *testing.T) {
for _, tc := range testCases {
r := ipSub(net.ParseIP(tc.lhs), net.ParseIP(tc.rhs))
if r != tc.expected {
t.Errorf("Expected %s, got %s", tc.expected, r)
t.Errorf("Expected %v, got %v", tc.expected, r)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%v is always safe, I guess, even if imprecise. should we just always use %v?

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/service/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestServiceRegistryCreate(t *testing.T) {
t.Errorf("Expected foo, but got %v", created_service.ID)
}
if created_service.CreationTimestamp.IsZero() {
t.Errorf("Expected timestamp to be set, got %:v", created_service.CreationTimestamp)
t.Errorf("Expected timestamp to be set, got: %v", created_service.CreationTimestamp)
}
if len(fakeCloud.Calls) != 0 {
t.Errorf("Unexpected call(s): %#v", fakeCloud.Calls)
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestGetInteger(t *testing.T) {
for _, test := range tests {
val := GetIntegerResource(test.res, test.name, test.def)
if val != test.expected {
t.Errorf("%s: expected: %d found %d", test.expected, val)
t.Errorf("expected: %d found %d", test.expected, val)
}
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestGetFloat(t *testing.T) {
for _, test := range tests {
val := GetFloatResource(test.res, test.name, test.def)
if val != test.expected {
t.Errorf("%s: expected: %d found %d", test.expected, val)
t.Errorf("%expected: %d found %d", test.expected, val)
}
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestGetString(t *testing.T) {
for _, test := range tests {
val := GetStringResource(test.res, test.name, test.def)
if val != test.expected {
t.Errorf("%s: expected: %d found %d", test.expected, val)
t.Errorf("expected: %d found %d", test.expected, val)
}
}
}
4 changes: 2 additions & 2 deletions pkg/runtime/jsonbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestResourceVersionerOfAPI(t *testing.T) {
t.Errorf("%s: unexpected error %#v", key, err)
}
if actual != testCase.Expected {
t.Errorf("%s: expected %d, got %d", key, testCase.Expected, actual)
t.Errorf("%s: expected %v, got %v", key, testCase.Expected, actual)
}
}

Expand Down Expand Up @@ -145,7 +145,7 @@ func TestResourceVersionerOfAPI(t *testing.T) {
t.Errorf("%s: unexpected error %#v", key, err)
}
if actual != "5" {
t.Errorf("%s: expected %d, got %d", key, "5", actual)
t.Errorf("%s: expected %v, got %v", key, "5", actual)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/predicates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestPodFitsPorts(t *testing.T) {
for _, test := range tests {
fits, err := PodFitsPorts(test.pod, test.existingPods, "machine")
if err != nil {
t.Errorf("unexpected error: %v")
t.Errorf("unexpected error: %v", err)
}
if test.fits != fits {
t.Errorf("%s: expected %v, saw %v", test.test, test.fits, fits)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tools/etcd_tools_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func TestWatchFromZeroIndex(t *testing.T) {
t.Fatalf("%s: expected a pod, got %#v", k, event.Object)
}
if actualPod.ResourceVersion != testCase.ExpectedVersion {
t.Errorf("%s: expected pod with resource version %d, Got %#v", k, testCase.ExpectedVersion, actualPod)
t.Errorf("%s: expected pod with resource version %v, Got %#v", k, testCase.ExpectedVersion, actualPod)
}
pod.ResourceVersion = testCase.ExpectedVersion
if e, a := pod, event.Object; !reflect.DeepEqual(e, a) {
Expand Down