@@ -18,8 +18,6 @@ package image
1818
1919import (
2020 "fmt"
21- "os"
22- "path/filepath"
2321 "strings"
2422 "testing"
2523 "time"
@@ -72,8 +70,7 @@ func TestImagePrune(t *testing.T) {
7270 ` , testutil .CommonImage )
7371
7472 buildCtx := data .Temp ().Path ()
75- err := os .WriteFile (filepath .Join (buildCtx , "Dockerfile" ), []byte (dockerfile ), 0o600 )
76- assert .NilError (helpers .T (), err )
73+ data .Temp ().Save (dockerfile , "Dockerfile" )
7774 helpers .Ensure ("build" , buildCtx )
7875 // After we rebuild with tag, docker will no longer show the <none> version from above
7976 // Swapping order does not change anything.
@@ -120,8 +117,7 @@ func TestImagePrune(t *testing.T) {
120117 ` , testutil .CommonImage )
121118
122119 buildCtx := data .Temp ().Path ()
123- err := os .WriteFile (filepath .Join (buildCtx , "Dockerfile" ), []byte (dockerfile ), 0o600 )
124- assert .NilError (helpers .T (), err )
120+ data .Temp ().Save (dockerfile , "Dockerfile" )
125121 helpers .Ensure ("build" , buildCtx )
126122 helpers .Ensure ("build" , "-t" , identifier , buildCtx )
127123 imgList := helpers .Capture ("images" )
@@ -164,8 +160,7 @@ CMD ["echo", "nerdctl-test-image-prune-filter-label"]
164160LABEL foo=bar
165161LABEL version=0.1` , testutil .CommonImage )
166162 buildCtx := data .Temp ().Path ()
167- err := os .WriteFile (filepath .Join (buildCtx , "Dockerfile" ), []byte (dockerfile ), 0o600 )
168- assert .NilError (helpers .T (), err )
163+ data .Temp ().Save (dockerfile , "Dockerfile" )
169164 helpers .Ensure ("build" , "-t" , data .Identifier (), buildCtx )
170165 imgList := helpers .Capture ("images" )
171166 assert .Assert (t , strings .Contains (imgList , data .Identifier ()), "Missing " + data .Identifier ())
@@ -204,8 +199,7 @@ LABEL version=0.1`, testutil.CommonImage)
204199RUN echo "Anything, so that we create actual content for docker to set the current time for CreatedAt"
205200CMD ["echo", "nerdctl-test-image-prune-until"]` , testutil .CommonImage )
206201 buildCtx := data .Temp ().Path ()
207- err := os .WriteFile (filepath .Join (buildCtx , "Dockerfile" ), []byte (dockerfile ), 0o600 )
208- assert .NilError (helpers .T (), err )
202+ data .Temp ().Save (dockerfile , "Dockerfile" )
209203 helpers .Ensure ("build" , "-t" , data .Identifier (), buildCtx )
210204 imgList := helpers .Capture ("images" )
211205 assert .Assert (t , strings .Contains (imgList , data .Identifier ()), "Missing " + data .Identifier ())
0 commit comments