@@ -56,6 +56,7 @@ func TestImagePrune(t *testing.T) {
5656 helpers .Anyhow ("rmi" , "-f" , data .Identifier ())
5757 },
5858 Setup : func (data test.Data , helpers test.Helpers ) {
59+ identifier := data .Identifier ()
5960 dockerfile := fmt .Sprintf (`FROM %s
6061 CMD ["echo", "nerdctl-test-image-prune"]
6162 ` , testutil .CommonImage )
@@ -64,22 +65,23 @@ func TestImagePrune(t *testing.T) {
6465 helpers .Ensure ("build" , buildCtx )
6566 // After we rebuild with tag, docker will no longer show the <none> version from above
6667 // Swapping order does not change anything.
67- helpers .Ensure ("build" , "-t" , data . Identifier () , buildCtx )
68+ helpers .Ensure ("build" , "-t" , identifier , buildCtx )
6869 imgList := helpers .Capture ("images" )
6970 assert .Assert (t , strings .Contains (imgList , "<none>" ), "Missing <none>" )
70- assert .Assert (t , strings .Contains (imgList , data . Identifier ()) , "Missing " + data . Identifier () )
71+ assert .Assert (t , strings .Contains (imgList , identifier ) , "Missing " + identifier )
7172 },
7273 Command : test .Command ("image" , "prune" , "--force" ),
7374 Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
75+ identifier := data .Identifier ()
7476 return & test.Expected {
7577 Output : test .All (
7678 func (stdout string , info string , t * testing.T ) {
77- assert .Assert (t , ! strings .Contains (stdout , data . Identifier () ), info )
79+ assert .Assert (t , ! strings .Contains (stdout , identifier ), info )
7880 },
7981 func (stdout string , info string , t * testing.T ) {
8082 imgList := helpers .Capture ("images" )
8183 assert .Assert (t , ! strings .Contains (imgList , "<none>" ), imgList )
82- assert .Assert (t , strings .Contains (imgList , data . Identifier () ), info )
84+ assert .Assert (t , strings .Contains (imgList , identifier ), info )
8385 },
8486 ),
8587 }
@@ -95,21 +97,23 @@ func TestImagePrune(t *testing.T) {
9597 // Cannot use a custom namespace with buildkitd right now, so, no parallel it is
9698 NoParallel : true ,
9799 Cleanup : func (data test.Data , helpers test.Helpers ) {
98- helpers .Anyhow ("rmi" , "-f" , data .Identifier ())
99- helpers .Anyhow ("rm" , "-f" , data .Identifier ())
100+ identifier := data .Identifier ()
101+ helpers .Anyhow ("rmi" , "-f" , identifier )
102+ helpers .Anyhow ("rm" , "-f" , identifier )
100103 },
101104 Setup : func (data test.Data , helpers test.Helpers ) {
105+ identifier := data .Identifier ()
102106 dockerfile := fmt .Sprintf (`FROM %s
103107 CMD ["echo", "nerdctl-test-image-prune"]
104108 ` , testutil .CommonImage )
105109
106110 buildCtx := testhelpers .CreateBuildContext (t , dockerfile )
107111 helpers .Ensure ("build" , buildCtx )
108- helpers .Ensure ("build" , "-t" , data . Identifier () , buildCtx )
112+ helpers .Ensure ("build" , "-t" , identifier , buildCtx )
109113 imgList := helpers .Capture ("images" )
110114 assert .Assert (t , strings .Contains (imgList , "<none>" ), "Missing <none>" )
111- assert .Assert (t , strings .Contains (imgList , data . Identifier ()) , "Missing " + data . Identifier () )
112- helpers .Ensure ("run" , "--name" , data . Identifier (), data . Identifier () )
115+ assert .Assert (t , strings .Contains (imgList , identifier ) , "Missing " + identifier )
116+ helpers .Ensure ("run" , "--name" , identifier , identifier )
113117 },
114118 Command : test .Command ("image" , "prune" , "--force" , "--all" ),
115119 Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
0 commit comments