@@ -27,8 +27,6 @@ import (
2727 "github.com/docker/cli-docs-tool/annotation"
2828 "github.com/spf13/cobra"
2929 "github.com/spf13/cobra/doc"
30- "github.com/stretchr/testify/assert"
31- "github.com/stretchr/testify/require"
3230)
3331
3432var (
@@ -248,16 +246,16 @@ func TestGenAllTree(t *testing.T) {
248246 setup ()
249247 tmpdir := t .TempDir ()
250248
251- // keep for testing
252- //tmpdir, err := os.MkdirTemp("", "cli-docs-tools")
253- //require.NoError(t, err)
254- //t.Log(tmpdir)
255-
256249 epoch , err := time .Parse ("2006-Jan-02" , "2020-Jan-10" )
257- require .NoError (t , err )
250+ if err != nil {
251+ t .Fatal (err )
252+ }
258253 t .Setenv ("SOURCE_DATE_EPOCH" , strconv .FormatInt (epoch .Unix (), 10 ))
259254
260- require .NoError (t , copyFile (path .Join ("fixtures" , "buildx_stop.pre.md" ), path .Join (tmpdir , "buildx_stop.md" )))
255+ err = copyFile (path .Join ("fixtures" , "buildx_stop.pre.md" ), path .Join (tmpdir , "buildx_stop.md" ))
256+ if err != nil {
257+ t .Fatal (err )
258+ }
261259
262260 c , err := New (Options {
263261 Root : dockerCmd ,
@@ -270,27 +268,37 @@ func TestGenAllTree(t *testing.T) {
270268 Manual : "Docker User Manuals" ,
271269 },
272270 })
273- require .NoError (t , err )
274- require .NoError (t , c .GenAllTree ())
271+ if err != nil {
272+ t .Fatal (err )
273+ }
274+ err = c .GenAllTree ()
275+ if err != nil {
276+ t .Fatal (err )
277+ }
275278
276279 seen := make (map [string ]struct {})
277280
278- _ = filepath .Walk ("fixtures" , func (path string , info fs.FileInfo , err error ) error {
281+ _ = filepath .Walk ("fixtures" , func (path string , info fs.FileInfo , _ error ) error {
279282 fname := filepath .Base (path )
280283 // ignore dirs and .pre.md files
281284 if info .IsDir () || strings .HasSuffix (fname , ".pre.md" ) {
282285 return nil
283286 }
284287 t .Run (fname , func (t * testing.T ) {
285288 seen [fname ] = struct {}{}
286- require .NoError (t , err )
287289
288290 bres , err := os .ReadFile (filepath .Join (tmpdir , fname ))
289- require .NoError (t , err )
291+ if err != nil {
292+ t .Fatal (err )
293+ }
290294
291295 bexc , err := os .ReadFile (path )
292- require .NoError (t , err )
293- assert .Equal (t , string (bexc ), string (bres ))
296+ if err != nil {
297+ t .Fatal (err )
298+ }
299+ if string (bexc ) != string (bres ) {
300+ t .Fatalf ("expected:\n %s\n got:\n %s" , string (bexc ), string (bres ))
301+ }
294302 })
295303 return nil
296304 })
0 commit comments