From bf0ccd64bd22c63c3574cb4b11f8b3c1a51c3196 Mon Sep 17 00:00:00 2001 From: Mario Carrion Date: Sat, 20 Jun 2020 23:40:43 -0400 Subject: [PATCH] markdown: tablewriter integration * olekukonko/tablewriter: render the result a bit of cleaner/clearer way. * senseyeio/diligent: update go.mod to use upstream version. --- .golangci.yml | 1 + README.md | 50 +++++++++----- cmd/versions/main.go | 2 +- go.mod | 5 +- go.sum | 8 ++- markdown/header_modules.go | 40 +++++------ markdown/header_modules_test.go | 36 +++++++--- markdown/markdown.go | 23 +++++-- markdown/packages.go | 74 ++++++++++---------- markdown/packages_test.go | 116 +++++++------------------------- 10 files changed, 167 insertions(+), 188 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3926416..265f428 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -12,3 +12,4 @@ issues: - path: _test\.go linters: - funlen + - lll diff --git a/README.md b/README.md index 3e07f42..1ec3f35 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ versions ## Example -:warning: New outputs are currently in development, at the moment Flavored Markdown is the only supported. +:warning: New outputs are currently in development, at the moment Flavored Markdown is the only supported one. -Using +Using: ``` versions ~/Repositories/versions/go.mod ~/Repositories/nit/go.mod @@ -46,24 +46,42 @@ versions ~/Repositories/versions/go.mod ~/Repositories/nit/go.mod The following output will be generated: ``` -| | github.com/MarioCarrion/nit | github.com/MarioCarrion/versions | -|--- | :---: | :---: | -| :white_check_mark: Go version| 1.13| 1.13 -| github.com/golangci/golangci-lint | v1.23.3 | v1.23.2 | -| :white_check_mark: github.com/google/go-cmp | v0.2.0 | | -| :white_check_mark: github.com/pkg/errors | v0.8.1 | | -| :white_check_mark: golang.org/x/mod | | v0.2.0 | +| | github.com/MarioCarrion/nit | github.com/MarioCarrion/versions | +|--------------------------------------------------------------|-----------------------------------|--------------------------------------------------------------------------------------------------------| +| :white_check_mark: Go | 1.14 | 1.14 | +| :white_check_mark: github.com/MarioCarrion/nit | | v0.6.5 | +| :white_check_mark: github.com/go-enry/go-license-detector/v4 | | v4.0.0
Apache License 2.0 permissive | +| :white_check_mark: github.com/golangci/golangci-lint | v1.23.8 | v1.23.8 | +| :white_check_mark: github.com/google/go-cmp | v0.4.0
BSD-3-Clause permissive | v0.4.0
BSD-3-Clause permissive | +| :white_check_mark: github.com/olekukonko/tablewriter | | v0.0.4
MIT License permissive | +| :white_check_mark: github.com/pkg/errors | v0.9.1
BSD-2-Clause permissive | | +| :white_check_mark: github.com/senseyeio/diligent | | v0.0.0-20191014201558-431d9a760f2d github.com/MarioCarrion/diligent v0.0.0-20200617184744-03fbc970a7f7 | +| :white_check_mark: golang.org/x/mod | | v0.2.0
BSD-3-Clause permissive | ``` Which renders like this in Markdown -| | github.com/MarioCarrion/nit | github.com/MarioCarrion/versions | -|--- | :---: | :---: | -| :white_check_mark: Go version| 1.13| 1.13 -| github.com/golangci/golangci-lint | v1.23.3 | v1.23.2 | -| :white_check_mark: github.com/google/go-cmp | v0.2.0 | | -| :white_check_mark: github.com/pkg/errors | v0.8.1 | | -| :white_check_mark: golang.org/x/mod | | v0.2.0 | +| | github.com/MarioCarrion/nit | github.com/MarioCarrion/versions | +|--------------------------------------------------------------|-----------------------------------|--------------------------------------------------------------------------------------------------------| +| :white_check_mark: Go | 1.14 | 1.14 | +| :white_check_mark: github.com/MarioCarrion/nit | | v0.6.5 | +| :white_check_mark: github.com/go-enry/go-license-detector/v4 | | v4.0.0
Apache License 2.0 permissive | +| :white_check_mark: github.com/golangci/golangci-lint | v1.23.8 | v1.23.8 | +| :white_check_mark: github.com/google/go-cmp | v0.4.0
BSD-3-Clause permissive | v0.4.0
BSD-3-Clause permissive | +| :white_check_mark: github.com/olekukonko/tablewriter | | v0.0.4
MIT License permissive | +| :white_check_mark: github.com/pkg/errors | v0.9.1
BSD-2-Clause permissive | | +| :white_check_mark: github.com/senseyeio/diligent | | v0.0.0-20191014201558-431d9a760f2d github.com/MarioCarrion/diligent v0.0.0-20200617184744-03fbc970a7f7 | +| :white_check_mark: golang.org/x/mod | | v0.2.0
BSD-3-Clause permissive | + +## Features + +* [X] Packages: license support. +* [ ] Packages: update availables support. + * [ ] Merge Requests creation for Gitlab. + * [ ] Pull Requests creation for Github. +* [ ] Packages: efferent and afferent metrics support. +* [ ] Output: Graphviz . +* [ ] Output: JSON. ## Development requirements diff --git a/cmd/versions/main.go b/cmd/versions/main.go index d454455..61869ba 100644 --- a/cmd/versions/main.go +++ b/cmd/versions/main.go @@ -23,8 +23,8 @@ func main() { os.Exit(1) } - // md := template.NewMarkdown(gomods, template.WithPackagesSorting(template.MarkdownPackagesSortingAlphabetically)) md := markdown.NewMarkdown(gomods, + markdown.WithModulesSorting(markdown.ModulesSortingAlphabetically), markdown.WithPackagesSorting(markdown.PackagesSortingAlphabeticallySupported), markdown.WithPackagesLicense(true)) diff --git a/go.mod b/go.mod index 9883f85..941c77c 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,7 @@ require ( github.com/go-enry/go-license-detector/v4 v4.0.0 github.com/golangci/golangci-lint v1.23.8 github.com/google/go-cmp v0.4.0 - github.com/senseyeio/diligent v0.0.0-20191014201558-431d9a760f2d + github.com/olekukonko/tablewriter v0.0.4 + github.com/senseyeio/diligent v0.0.0-20200618092025-134592e3dea7 golang.org/x/mod v0.2.0 ) - -replace github.com/senseyeio/diligent => github.com/MarioCarrion/diligent v0.0.0-20200617184744-03fbc970a7f7 diff --git a/go.sum b/go.sum index 8817f8d..e6853e6 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/MarioCarrion/diligent v0.0.0-20200617184744-03fbc970a7f7 h1:nNURpLkriAFSeo4UtT5/PbK8eZGMSpiGHwgJ6LJK/NA= -github.com/MarioCarrion/diligent v0.0.0-20200617184744-03fbc970a7f7/go.mod h1:6ByW93XxJz+TbIDtCtqo729IzEO0ucg4eNblSipDuqY= github.com/MarioCarrion/nit v0.6.5 h1:Rd2/dtg5i87jfOHzJLAfAqQm3WPf5BEWLJV97gexp8Q= github.com/MarioCarrion/nit v0.6.5/go.mod h1:am3sU2DxXpNY7XjkVl95x9siikCzGQ/zrNW7Ao0dOcU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -220,6 +218,8 @@ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaa github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -240,6 +240,8 @@ github.com/neurosnap/sentences v1.0.6/go.mod h1:pg1IapvYpWCJJm/Etxeh0+gtMf1rI1ST github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= +github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -278,6 +280,8 @@ github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0 github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83 h1:AtnWoOvTioyDXFvu96MWEeE8qj4COSQnJogzLy/u41A= github.com/securego/gosec v0.0.0-20200103095621-79fbf3af8d83/go.mod h1:vvbZ2Ae7AzSq3/kywjUDxSNq2SJ27RxCz2un0H3ePqE= +github.com/senseyeio/diligent v0.0.0-20200618092025-134592e3dea7 h1:oB+QlIUSmpoami8aRZPFV+hbIM/RJV6s6MwVLf9rBVQ= +github.com/senseyeio/diligent v0.0.0-20200618092025-134592e3dea7/go.mod h1:6ByW93XxJz+TbIDtCtqo729IzEO0ucg4eNblSipDuqY= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc= diff --git a/markdown/header_modules.go b/markdown/header_modules.go index 964c5f0..ea58484 100644 --- a/markdown/header_modules.go +++ b/markdown/header_modules.go @@ -1,8 +1,8 @@ package markdown import ( + "fmt" "sort" - "strings" "github.com/MarioCarrion/versions" ) @@ -37,38 +37,32 @@ func newHeader(sorting ModulesSorting, same bool, values []versions.Module) head } } -func (h header) String() string { - var str strings.Builder +func (h header) GoVersions() []string { + res := make([]string, len(h.modules)+1) - // Modules header + var str string - str.WriteString("|") - - for _, mod := range h.modules { - str.WriteString(" | ") - str.WriteString(string(mod.Name)) + if h.same { + str = ":white_check_mark: " } - str.WriteString(" |\n") - - // Modules Go Versions - - str.WriteString("| ") + res[0] = fmt.Sprintf("%sGo", str) - if h.same { - str.WriteString(":white_check_mark: ") + for i, mod := range h.modules { + res[i+1] = string(mod.GoVersion) } - str.WriteString("Go") + return res +} + +func (h header) Names() []string { + res := make([]string, len(h.modules)+1) - for _, mod := range h.modules { - str.WriteString(" | ") - str.WriteString(string(mod.GoVersion)) + for i, mod := range h.modules { + res[i+1] = string(mod.Name) } - str.WriteString(" |\n") - - return str.String() + return res } func (m modules) Len() int { diff --git a/markdown/header_modules_test.go b/markdown/header_modules_test.go index 510ff9d..e1a96e5 100644 --- a/markdown/header_modules_test.go +++ b/markdown/header_modules_test.go @@ -71,7 +71,7 @@ func Test_module(t *testing.T) { //- header -func Test_header_String(t *testing.T) { +func Test_header(t *testing.T) { t.Parallel() type ( @@ -80,12 +80,17 @@ func Test_header_String(t *testing.T) { same bool values []versions.Module } + + expected struct { + goVersions []string + names []string + } ) tests := []struct { name string input input - expected string + expected expected }{ { "OK: ModulesSortingAsInput and Same", @@ -112,9 +117,10 @@ func Test_header_String(t *testing.T) { }, }, }, - `| | fixture.com/new_module_replace | fixture.com/new_module_indirect | fixture.com/new_module_simple | -| :white_check_mark: Go | 1.14 | 1.14 | 1.14 | -`, + expected{ + goVersions: []string{":white_check_mark: Go", "1.14", "1.14", "1.14"}, + names: []string{"", "fixture.com/new_module_replace", "fixture.com/new_module_indirect", "fixture.com/new_module_simple"}, + }, }, { "OK: ModulesSortingAlphabetically and Different", @@ -141,9 +147,10 @@ func Test_header_String(t *testing.T) { }, }, }, - `| | fixture.com/new_module_indirect | fixture.com/new_module_replace | fixture.com/new_module_simple | -| Go | 1.15 | 1.14 | 1.13 | -`, + expected{ + goVersions: []string{"Go", "1.15", "1.14", "1.13"}, + names: []string{"", "fixture.com/new_module_indirect", "fixture.com/new_module_replace", "fixture.com/new_module_simple"}, + }, }, } @@ -152,9 +159,16 @@ func Test_header_String(t *testing.T) { t.Run(test.name, func(t *testing.T) { t.Parallel() - got := newHeader(test.input.sorting, test.input.same, test.input.values).String() - if got != test.expected { - t.Fatalf("expected %s, got %s", test.expected, got) + header := newHeader(test.input.sorting, test.input.same, test.input.values) + + goVersions := header.GoVersions() + if !cmp.Equal(goVersions, test.expected.goVersions) { + t.Fatalf("expected values do not match: %s", cmp.Diff(goVersions, test.expected.goVersions)) + } + + names := header.Names() + if !cmp.Equal(names, test.expected.names) { + t.Fatalf("expected values do not match: %s", cmp.Diff(names, test.expected.names)) } }) } diff --git a/markdown/markdown.go b/markdown/markdown.go index df81d55..39008fa 100644 --- a/markdown/markdown.go +++ b/markdown/markdown.go @@ -3,7 +3,9 @@ package markdown import ( - "strings" + "os" + + "github.com/olekukonko/tablewriter" "github.com/MarioCarrion/versions" ) @@ -102,10 +104,21 @@ func (m Markdown) String() string { header := newHeader(m.modulesSortBy, m.versions.GoVersions.IsSame(), mods) pkgs := newPackages(m.versions, header.modules, m.packagesSortBy, m.packagesShowLicense) - var str strings.Builder + var data [][]string + + data = append(data, header.GoVersions()) + data = append(data, pkgs.Values()...) + + table := tablewriter.NewWriter(os.Stdout) + table.SetHeader(header.Names()) + table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false}) + table.SetCenterSeparator("|") + table.SetAutoFormatHeaders(false) + table.SetReflowDuringAutoWrap(false) + table.SetAutoWrapText(false) - str.WriteString(header.String()) - str.WriteString(pkgs.String()) + table.AppendBulk(data) + table.Render() - return str.String() + return "" } diff --git a/markdown/packages.go b/markdown/packages.go index ead8c70..893c2f6 100644 --- a/markdown/packages.go +++ b/markdown/packages.go @@ -1,6 +1,7 @@ package markdown import ( + "fmt" "sort" "strings" @@ -59,42 +60,45 @@ func newPackages(vs versions.Versions, modules []module, sorting PackagesSorting return res } -func (p packageSet) String() string { - var str strings.Builder +func (p packageSet) Values() []string { + res := make([]string, len(p.packages)+1) - str.WriteString("| ") + var str string - if p.same { - str.WriteString(":white_check_mark: ") + if p.same { // XXX: Make emoji option configurable + // str = "✓ " + // str = "✅" + str = ":white_check_mark: " } - str.WriteString(string(p.Name)) + res[0] = fmt.Sprintf("%s%s", str, p.Name) - for _, v := range p.packages { - str.WriteString(" | ") - str.WriteString(v.Version) + for i, v := range p.packages { + var b strings.Builder + + b.WriteString(v.Version) if v.ReplacedPath != "" { - str.WriteString(" - ") - str.WriteString(v.ReplacedPath) + b.WriteString(" ") + b.WriteString(v.ReplacedPath) } if v.ReplacedVersion != "" { - str.WriteString("/") - str.WriteString(v.ReplacedVersion) + b.WriteString(" ") + b.WriteString(v.ReplacedVersion) } if p.showLicense && v.License.Identifier != "" { - str.WriteString("
") - str.WriteString(v.License.Name) - str.WriteString(" - ") - str.WriteString(string(v.License.Category)) + b.WriteString("
") + b.WriteString(string(v.License.Category)) + b.WriteString(" ") + b.WriteString(v.License.Name) } - } - str.WriteString(" |\n") + res[i+1] = b.String() + } - return str.String() + return res } func (p packageSets) Len() int { @@ -113,28 +117,24 @@ func (p packageSets) Swap(i, j int) { //- -func (p packageSets) String() string { - var str strings.Builder +func (p packages) Values() [][]string { + var res [][]string - sets := []packageSet(p) + if len(p.same) > 0 { + setsSame := []packageSet(p.same) - for _, s := range sets { - str.WriteString(s.String()) + for _, val := range setsSame { + res = append(res, val.Values()) + } } - return str.String() -} + if len(p.different) > 0 { + setsSame := []packageSet(p.different) -func (p packages) String() string { - var str strings.Builder - - if p.same != nil { - str.WriteString(p.same.String()) - } - - if p.different != nil { - str.WriteString(p.different.String()) + for _, val := range setsSame { + res = append(res, val.Values()) + } } - return str.String() + return res } diff --git a/markdown/packages_test.go b/markdown/packages_test.go index 57214c9..268a2a9 100644 --- a/markdown/packages_test.go +++ b/markdown/packages_test.go @@ -158,43 +158,47 @@ func Test_newPackages(t *testing.T) { tests := []struct { name string input input - expected string + expected [][]string }{ { "OK: PackagesSortingAsFound", newInput(PackagesSortingAsFound, false), - `| :white_check_mark: pkg1 | v1 - fixtures/license/valid | v1 - fixtures/license/valid | -| :white_check_mark: abc | v1 | | -| diff | v2 | v1 | -| adiff | v2 | v1 | -`, + [][]string{ + {":white_check_mark: pkg1", "v1 fixtures/license/valid", "v1 fixtures/license/valid"}, + {":white_check_mark: abc", "v1", ""}, + {"diff", "v2", "v1"}, + {"adiff", "v2", "v1"}, + }, }, { "OK: PackagesSortingAsFound with License", newInput(PackagesSortingAsFound, true), - `| :white_check_mark: pkg1 | v1 - fixtures/license/valid | v1 - fixtures/license/valid | -| :white_check_mark: abc | v1
LicenseName - permissive | | -| diff | v2 | v1 | -| adiff | v2 | v1 | -`, + [][]string{ + {":white_check_mark: pkg1", "v1 fixtures/license/valid", "v1 fixtures/license/valid"}, + {":white_check_mark: abc", "v1
permissive LicenseName", ""}, + {"diff", "v2", "v1"}, + {"adiff", "v2", "v1"}, + }, }, { "OK: PackagesSortingAlphabeticallySupported", newInput(PackagesSortingAlphabeticallySupported, false), - `| :white_check_mark: abc | v1 | | -| :white_check_mark: pkg1 | v1 - fixtures/license/valid | v1 - fixtures/license/valid | -| adiff | v2 | v1 | -| diff | v2 | v1 | -`, + [][]string{ + {":white_check_mark: abc", "v1", ""}, + {":white_check_mark: pkg1", "v1 fixtures/license/valid", "v1 fixtures/license/valid"}, + {"adiff", "v2", "v1"}, + {"diff", "v2", "v1"}, + }, }, { "OK: PackagesSortingAlphabetically", newInput(PackagesSortingAlphabetically, false), - `| :white_check_mark: abc | v1 | | -| adiff | v2 | v1 | -| diff | v2 | v1 | -| :white_check_mark: pkg1 | v1 - fixtures/license/valid | v1 - fixtures/license/valid | -`, + [][]string{ + {":white_check_mark: abc", "v1", ""}, + {"adiff", "v2", "v1"}, + {"diff", "v2", "v1"}, + {":white_check_mark: pkg1", "v1 fixtures/license/valid", "v1 fixtures/license/valid"}, + }, }, } @@ -214,7 +218,7 @@ func Test_newPackages(t *testing.T) { } pkgs := newPackages(versions, test.input.modules.values, test.input.sorting, test.input.showLicense) - if got := pkgs.String(); !cmp.Equal(got, test.expected) { + if got := pkgs.Values(); !cmp.Equal(got, test.expected) { t.Fatalf("expected values do not match: %s", cmp.Diff(got, test.expected)) } }) @@ -263,71 +267,3 @@ func Test_packageSets_Sort(t *testing.T) { }) } } - -func Test_packageSets_String(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - input packageSets - expected string - }{ - { - "OK", - []packageSet{ - { - same: true, - Name: "name", - packages: []versions.Package{ - { - Name: "name", - Version: "v1", - IsIndirect: true, - ReplacedPath: "rpath", - ReplacedVersion: "rversion", - }, - { - Name: "name", - Version: "v2", - IsIndirect: true, - ReplacedPath: "rpath", - ReplacedVersion: "rversion", - }, - }, - }, - { - same: false, - Name: "another", - packages: []versions.Package{ - { - Name: "another", - Version: "v1", - IsIndirect: true, - }, - { - Name: "another", - Version: "v2", - IsIndirect: true, - ReplacedPath: "rpath", - ReplacedVersion: "rversion", - }, - }, - }, - }, - `| :white_check_mark: name | v1 - rpath/rversion | v2 - rpath/rversion | -| another | v1 | v2 - rpath/rversion | -`, - }, - } - - for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { - t.Parallel() - - if got := test.input.String(); !cmp.Equal(got, test.expected) { - t.Fatalf("expected values do not match: %s", cmp.Diff(got, test.expected)) - } - }) - } -}