Skip to content

Commit 93da517

Browse files
author
switchupcb
committed
update non-alphabetical tests
includes refactor
1 parent e50ba33 commit 93da517

File tree

6 files changed

+205
-204
lines changed

6 files changed

+205
-204
lines changed

cli/parser/ast.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import (
55
"go/token"
66
)
77

8+
const copygenInterfaceName = "Copygen"
9+
810
// assertCopygenInterface determines if an ast.GenDecl is a Copygen Interface by type assertion.
911
func assertCopygenInterface(x *ast.GenDecl) (*ast.InterfaceType, bool) {
1012
if x.Tok == token.TYPE {
1113
for _, spec := range x.Specs {
1214
if ts, ok := spec.(*ast.TypeSpec); ok {
13-
if it, ok := ts.Type.(*ast.InterfaceType); ok && ts.Name.Name == "Copygen" {
15+
if it, ok := ts.Type.(*ast.InterfaceType); ok && ts.Name.Name == copygenInterfaceName {
1416
return it, true
1517
}
1618
}

cli/parser/function.go

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/switchupcb/copygen/cli/parser/options"
1010
)
1111

12-
const copygenInterfaceName = "Copygen"
13-
1412
// parseFunctions parses the AST for functions in the setup file.
1513
// astcopygen is used to assign options from *ast.Comments.
1614
func (p *Parser) parseFunctions(copygen *ast.InterfaceType) ([]models.Function, error) {

cli/parser/parse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func Parse(gen *models.Generator) error {
107107
return fmt.Errorf("an error occurred parsing the specified .go setup file: %v\n%w", gen.Setpath, err)
108108
}
109109

110-
// Parse the setup file's `type Copygen Interface` for the Keep (and set options in the process).
110+
// Parse the setup file's `type Copygen Interface` for the Keep (and create Options in the process).
111111
if err := p.Keep(p.Config.SetupFile); err != nil {
112112
return fmt.Errorf("%w", err)
113113
}

examples/_tests/cyclic/copygen.go

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)