diff --git a/clidocstool_man_test.go b/clidocstool_man_test.go index f847250..7a4fc68 100644 --- a/clidocstool_man_test.go +++ b/clidocstool_man_test.go @@ -25,8 +25,6 @@ import ( "time" "github.com/spf13/cobra/doc" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) //nolint:errcheck @@ -35,10 +33,15 @@ func TestGenManTree(t *testing.T) { tmpdir := t.TempDir() epoch, err := time.Parse("2006-Jan-02", "2020-Jan-10") - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } t.Setenv("SOURCE_DATE_EPOCH", strconv.FormatInt(epoch.Unix(), 10)) - require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md"))) + err = copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")) + if err != nil { + t.Fatal(err) + } c, err := New(Options{ Root: dockerCmd, @@ -51,8 +54,14 @@ func TestGenManTree(t *testing.T) { Manual: "Docker User Manuals", }, }) - require.NoError(t, err) - require.NoError(t, c.GenManTree(dockerCmd)) + if err != nil { + t.Fatal(err) + } + + err = c.GenManTree(dockerCmd) + if err != nil { + t.Fatal(err) + } seen := make(map[string]struct{}) remanpage := regexp.MustCompile(`\.\d+$`) @@ -65,14 +74,19 @@ func TestGenManTree(t *testing.T) { } t.Run(fname, func(t *testing.T) { seen[fname] = struct{}{} - require.NoError(t, err) bres, err := os.ReadFile(filepath.Join(tmpdir, fname)) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } bexc, err := os.ReadFile(path) - require.NoError(t, err) - assert.Equal(t, string(bexc), string(bres)) + if err != nil { + t.Fatal(err) + } + if string(bexc) != string(bres) { + t.Fatalf("expected:\n%s\ngot:\n%s", string(bexc), string(bres)) + } }) return nil }) diff --git a/clidocstool_md_test.go b/clidocstool_md_test.go index 2abf72c..1ff7d06 100644 --- a/clidocstool_md_test.go +++ b/clidocstool_md_test.go @@ -21,8 +21,6 @@ import ( "path/filepath" "strings" "testing" - - "github.com/stretchr/testify/require" ) //nolint:errcheck @@ -30,15 +28,23 @@ func TestGenMarkdownTree(t *testing.T) { setup() tmpdir := t.TempDir() - require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md"))) + err := copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")) + if err != nil { + t.Fatal(err) + } c, err := New(Options{ Root: dockerCmd, SourceDir: tmpdir, Plugin: false, }) - require.NoError(t, err) - require.NoError(t, c.GenMarkdownTree(dockerCmd)) + if err != nil { + t.Fatal(err) + } + err = c.GenMarkdownTree(dockerCmd) + if err != nil { + t.Fatal(err) + } seen := make(map[string]struct{}) @@ -50,14 +56,19 @@ func TestGenMarkdownTree(t *testing.T) { } t.Run(fname, func(t *testing.T) { seen[fname] = struct{}{} - require.NoError(t, err) bres, err := os.ReadFile(filepath.Join(tmpdir, fname)) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } bexc, err := os.ReadFile(path) - require.NoError(t, err) - require.Equal(t, string(bexc), string(bres)) + if err != nil { + t.Fatal(err) + } + if string(bexc) != string(bres) { + t.Fatalf("expected:\n%s\ngot:\n%s", string(bexc), string(bres)) + } }) return nil }) diff --git a/clidocstool_test.go b/clidocstool_test.go index 12bd3a1..713d775 100644 --- a/clidocstool_test.go +++ b/clidocstool_test.go @@ -27,8 +27,6 @@ import ( "github.com/docker/cli-docs-tool/annotation" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) var ( @@ -249,15 +247,22 @@ func TestGenAllTree(t *testing.T) { tmpdir := t.TempDir() // keep for testing - //tmpdir, err := os.MkdirTemp("", "cli-docs-tools") - //require.NoError(t, err) - //t.Log(tmpdir) + // tmpdir, err := os.MkdirTemp("", "cli-docs-tools") + // if err != nil { + // t.Fatal(err) + // } + // t.Log(tmpdir) epoch, err := time.Parse("2006-Jan-02", "2020-Jan-10") - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } t.Setenv("SOURCE_DATE_EPOCH", strconv.FormatInt(epoch.Unix(), 10)) - require.NoError(t, copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md"))) + err = copyFile(path.Join("fixtures", "buildx_stop.pre.md"), path.Join(tmpdir, "buildx_stop.md")) + if err != nil { + t.Fatal(err) + } c, err := New(Options{ Root: dockerCmd, @@ -270,12 +275,17 @@ func TestGenAllTree(t *testing.T) { Manual: "Docker User Manuals", }, }) - require.NoError(t, err) - require.NoError(t, c.GenAllTree()) + if err != nil { + t.Fatal(err) + } + err = c.GenAllTree() + if err != nil { + t.Fatal(err) + } seen := make(map[string]struct{}) - _ = filepath.Walk("fixtures", func(path string, info fs.FileInfo, err error) error { + _ = filepath.Walk("fixtures", func(path string, info fs.FileInfo, _ error) error { fname := filepath.Base(path) // ignore dirs and .pre.md files if info.IsDir() || strings.HasSuffix(fname, ".pre.md") { @@ -283,14 +293,19 @@ func TestGenAllTree(t *testing.T) { } t.Run(fname, func(t *testing.T) { seen[fname] = struct{}{} - require.NoError(t, err) bres, err := os.ReadFile(filepath.Join(tmpdir, fname)) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } bexc, err := os.ReadFile(path) - require.NoError(t, err) - assert.Equal(t, string(bexc), string(bres)) + if err != nil { + t.Fatal(err) + } + if string(bexc) != string(bres) { + t.Fatalf("expected:\n%s\ngot:\n%s", string(bexc), string(bres)) + } }) return nil }) diff --git a/clidocstool_yaml_test.go b/clidocstool_yaml_test.go index e412fb0..6d5d379 100644 --- a/clidocstool_yaml_test.go +++ b/clidocstool_yaml_test.go @@ -20,9 +20,6 @@ import ( "path/filepath" "strings" "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) //nolint:errcheck @@ -35,8 +32,13 @@ func TestGenYamlTree(t *testing.T) { SourceDir: tmpdir, Plugin: false, }) - require.NoError(t, err) - require.NoError(t, c.GenYamlTree(dockerCmd)) + if err != nil { + t.Fatal(err) + } + err = c.GenYamlTree(dockerCmd) + if err != nil { + t.Fatal(err) + } seen := make(map[string]struct{}) @@ -48,14 +50,19 @@ func TestGenYamlTree(t *testing.T) { } t.Run(fname, func(t *testing.T) { seen[fname] = struct{}{} - require.NoError(t, err) bres, err := os.ReadFile(filepath.Join(tmpdir, fname)) - require.NoError(t, err) + if err != nil { + t.Fatal(err) + } bexc, err := os.ReadFile(path) - require.NoError(t, err) - assert.Equal(t, string(bexc), string(bres)) + if err != nil { + t.Fatal(err) + } + if string(bexc) != string(bres) { + t.Fatalf("expected:\n%s\ngot:\n%s", string(bexc), string(bres)) + } }) return nil }) diff --git a/go.mod b/go.mod index 5955c4d..d86d5c3 100644 --- a/go.mod +++ b/go.mod @@ -5,15 +5,11 @@ go 1.23.0 require ( github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 - github.com/stretchr/testify v1.9.0 go.yaml.in/yaml/v3 v3.0.4 ) require ( github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 063cb7a..8138810 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= @@ -14,11 +10,7 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=