Use t.Run for /pkg/cri tests
A majority of the tests in /pkg/cri are testing/validating multiple things per test (generally spec or options validations). This flow lends itself well to using *testing.T's Run method to run each thing as a subtest so `go test` output can actually display which subtest failed/passed. Some of the tests in the packages in pkg/cri already did this, but a bunch simply logged what sub-testcase was currently running without invoking t.Run. Signed-off-by: Daniel Canter <dcanter@microsoft.com>
This commit is contained in:
		| @@ -70,13 +70,15 @@ func TestToCRISandbox(t *testing.T) { | ||||
| 			expectedState: runtime.PodSandboxState_SANDBOX_NOTREADY, | ||||
| 		}, | ||||
| 	} { | ||||
| 		status := sandboxstore.Status{ | ||||
| 			CreatedAt: createdAt, | ||||
| 			State:     test.state, | ||||
| 		} | ||||
| 		expect.State = test.expectedState | ||||
| 		s := toCRISandbox(meta, status) | ||||
| 		assert.Equal(t, expect, s, desc) | ||||
| 		t.Run(desc, func(t *testing.T) { | ||||
| 			status := sandboxstore.Status{ | ||||
| 				CreatedAt: createdAt, | ||||
| 				State:     test.state, | ||||
| 			} | ||||
| 			expect.State = test.expectedState | ||||
| 			s := toCRISandbox(meta, status) | ||||
| 			assert.Equal(t, expect, s, desc) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -201,8 +203,9 @@ func TestFilterSandboxes(t *testing.T) { | ||||
| 			expect: []*runtime.PodSandbox{testSandboxes[2]}, | ||||
| 		}, | ||||
| 	} { | ||||
| 		t.Logf("TestCase: %s", desc) | ||||
| 		filtered := c.filterCRISandboxes(testSandboxes, test.filter) | ||||
| 		assert.Equal(t, test.expect, filtered, desc) | ||||
| 		t.Run(desc, func(t *testing.T) { | ||||
| 			filtered := c.filterCRISandboxes(testSandboxes, test.filter) | ||||
| 			assert.Equal(t, test.expect, filtered, desc) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Canter
					Daniel Canter