-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix @cwd add tests for multiple package converters
- Loading branch information
Showing
6 changed files
with
192 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
input: | ||
pkg1/input.go: | | ||
package pkg1 | ||
// goverter:converter | ||
// goverter:output @cwd/generated/output.go | ||
type Converter interface { | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
patterns: | ||
- github.com/jmattheis/goverter/execution/pkg1 | ||
success: | ||
- generated/output.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import pkg1 "github.com/jmattheis/goverter/execution/pkg1" | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source pkg1.Input) pkg1.Output { | ||
var pkg1Output pkg1.Output | ||
pkg1Output.ID = source.ID | ||
return pkg1Output | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
input: | ||
model/model.go: | | ||
package model | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
pkg1/input.go: | | ||
package pkg1 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
pkg2/input.go: | | ||
package pkg2 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter2 interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
patterns: | ||
- github.com/jmattheis/goverter/execution/pkg1 | ||
- github.com/jmattheis/goverter/execution/pkg2 | ||
success: | ||
- generated/output.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
type Converter2Impl struct{} | ||
func (c *Converter2Impl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
input: | ||
model/model.go: | | ||
package model | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
pkg1/input.go: | | ||
package pkg1 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
pkg2/input.go: | | ||
package pkg2 | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
// goverter:converter | ||
// goverter:output ../generated/output.go | ||
type Converter2 interface { | ||
Convert(source model.Input) model.Output | ||
} | ||
patterns: | ||
- github.com/jmattheis/goverter/execution/... | ||
success: | ||
- generated/output.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
import model "github.com/jmattheis/goverter/execution/model" | ||
type Converter2Impl struct{} | ||
func (c *Converter2Impl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} | ||
type ConverterImpl struct{} | ||
func (c *ConverterImpl) Convert(source model.Input) model.Output { | ||
var modelOutput model.Output | ||
modelOutput.ID = source.ID | ||
return modelOutput | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
// goverter:outputPackage pkg1 | ||
type Converter interface { | ||
Convert(source Input) Output | ||
} | ||
// goverter:converter | ||
// goverter:outputPackage pkg2 | ||
type Converter2 interface { | ||
Convert(source Input) Output | ||
} | ||
type Input struct { | ||
ID int | ||
} | ||
type Output struct { | ||
ID int | ||
} | ||
error: |- | ||
Error creating converters | ||
/ABSOLUTE/execution/input.go | ||
github.com/jmattheis/goverter/execution.Converter | ||
and | ||
/ABSOLUTE/execution/input.go | ||
github.com/jmattheis/goverter/execution.Converter2 | ||
Cannot use different packages | ||
pkg1 | ||
pkg2 | ||
in the same output file: | ||
/ABSOLUTE/execution/generated/generated.go |