From 0209ce9137222f2816991b7a4ba740e6a750a430 Mon Sep 17 00:00:00 2001 From: zhangxiaoyu-zidif Date: Mon, 8 Jan 2018 12:03:55 +0800 Subject: [PATCH] fix csi attach ut print --- pkg/volume/csi/csi_attacher_test.go | 6 +++--- pkg/volume/csi/csi_client_test.go | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/volume/csi/csi_attacher_test.go b/pkg/volume/csi/csi_attacher_test.go index 2b809eb5d64..308b646d4ce 100644 --- a/pkg/volume/csi/csi_attacher_test.go +++ b/pkg/volume/csi/csi_attacher_test.go @@ -110,13 +110,13 @@ func TestAttacherAttach(t *testing.T) { // attacher loop for i, tc := range testCases { - t.Log("test case: ", tc.name) + t.Logf("test case: %s", tc.name) spec := volume.NewSpecFromPersistentVolume(makeTestPV(fmt.Sprintf("test-pv%d", i), 10, tc.driverName, tc.volumeName), false) go func(id, nodename string, fail bool) { attachID, err := csiAttacher.Attach(spec, types.NodeName(nodename)) if !fail && err != nil { - t.Error("was not expecting failure, but got err: ", err) + t.Errorf("expecting no failure, but got err: %v", err) } if attachID != id && !fail { t.Errorf("expecting attachID %v, got %v", id, attachID) @@ -178,7 +178,7 @@ func TestAttacherWaitForVolumeAttachment(t *testing.T) { } for i, tc := range testCases { - t.Logf("running test: %v", tc.name) + t.Logf("running test: %s", tc.name) pvName := fmt.Sprintf("test-pv-%d", i) volID := fmt.Sprintf("test-vol-%d", i) attachID := getAttachmentName(volID, testDriver, nodeName) diff --git a/pkg/volume/csi/csi_client_test.go b/pkg/volume/csi/csi_client_test.go index 744f2bcc8cc..b14d09a0b7e 100644 --- a/pkg/volume/csi/csi_client_test.go +++ b/pkg/volume/csi/csi_client_test.go @@ -52,12 +52,12 @@ func TestClientAssertSupportedVersion(t *testing.T) { } for _, tc := range testCases { - t.Log("case: ", tc.testName) + t.Logf("test case: %s", tc.testName) client := setupClient(t) client.idClient.(*fake.IdentityClient).SetNextError(tc.err) err := client.AssertSupportedVersion(grpctx.Background(), tc.ver) if tc.mustFail && err == nil { - t.Error("must fail, but err = nil") + t.Error("test must fail, but err = nil") } } } @@ -74,12 +74,12 @@ func TestClientNodeProbe(t *testing.T) { } for _, tc := range testCases { - t.Log("case: ", tc.testName) + t.Logf("test case: %s", tc.testName) client := setupClient(t) client.nodeClient.(*fake.NodeClient).SetNextError(tc.err) err := client.NodeProbe(grpctx.Background(), tc.ver) if tc.mustFail && err == nil { - t.Error("must fail, but err = nil") + t.Error("test must fail, but err = nil") } } } @@ -103,7 +103,7 @@ func TestClientNodePublishVolume(t *testing.T) { client := setupClient(t) for _, tc := range testCases { - t.Log("case: ", tc.name) + t.Logf("test case: %s", tc.name) client.nodeClient.(*fake.NodeClient).SetNextError(tc.err) err := client.NodePublishVolume( grpctx.Background(), @@ -117,7 +117,7 @@ func TestClientNodePublishVolume(t *testing.T) { ) if tc.mustFail && err == nil { - t.Error("must fail, but err is nil: ", err) + t.Error("test must fail, but err is nil") } } } @@ -139,11 +139,11 @@ func TestClientNodeUnpublishVolume(t *testing.T) { client := setupClient(t) for _, tc := range testCases { - t.Log("case: ", tc.name) + t.Logf("test case: %s", tc.name) client.nodeClient.(*fake.NodeClient).SetNextError(tc.err) err := client.NodeUnpublishVolume(grpctx.Background(), tc.volID, tc.targetPath) if tc.mustFail && err == nil { - t.Error("must fail, but err is nil: ", err) + t.Error("test must fail, but err is nil") } } }