mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-12 04:06:44 +00:00
copy config.yaml to docker image enable external usage of dashboard package gofmt fix comment use packr for assets add gobuffalo/packr dependency add dependencies fix pointer issues add output-file option
40 lines
699 B
Go
40 lines
699 B
Go
package gogen
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/gobuffalo/genny"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_PackageName(t *testing.T) {
|
|
table := []struct {
|
|
pass bool
|
|
name string
|
|
body string
|
|
pkg string
|
|
}{
|
|
{true, "version.go", "package foo\n", "foo"},
|
|
{true, "foo/version.go", "package foo\n", "foo"},
|
|
{true, "foo/version.go", "", "foo"},
|
|
{false, "", "", ""},
|
|
}
|
|
|
|
for _, tt := range table {
|
|
t.Run(tt.name+"|"+tt.body, func(st *testing.T) {
|
|
r := require.New(st)
|
|
f := genny.NewFile(tt.name, strings.NewReader(tt.body))
|
|
|
|
pkg, err := PackageName(f)
|
|
if tt.pass {
|
|
r.NoError(err)
|
|
} else {
|
|
r.Error(err)
|
|
}
|
|
r.Equal(tt.pkg, pkg)
|
|
})
|
|
}
|
|
|
|
}
|