-
-
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.
test: add tests for boolean settings, pattern errors and invalid map
- Loading branch information
Showing
5 changed files
with
172 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
// goverter:useZeroValueOnPointerInconsistency abc | ||
type Converter interface { | ||
Convert(Input) Output | ||
} | ||
type Input struct { Name string } | ||
type Output struct { Name string } | ||
error: |- | ||
error parsing 'goverter:useZeroValueOnPointerInconsistency' at | ||
/ABSOLUTE/execution/input.go:5:1 | ||
github.com/jmattheis/goverter/execution.Converter | ||
invalid boolean value: 'abc' must be one of 'yes', 'no' |
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,18 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
// goverter:useZeroValueOnPointerInconsistency 1 2 | ||
type Converter interface { | ||
Convert(Input) Output | ||
} | ||
type Input struct { Name string } | ||
type Output struct { Name string } | ||
error: |- | ||
error parsing 'goverter:useZeroValueOnPointerInconsistency' at | ||
/ABSOLUTE/execution/input.go:5:1 | ||
github.com/jmattheis/goverter/execution.Converter | ||
expected at most one value but got 2: []string{"1", "2"} |
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,23 @@ | ||
input: | ||
input.go: | | ||
package structs | ||
// goverter:converter | ||
type Converter interface { | ||
// goverter:map | Malformed | ||
ConvertPerson(source Person) APIPerson | ||
} | ||
type Person struct { | ||
Name string | ||
} | ||
type APIPerson struct { | ||
Name string | ||
} | ||
error: |- | ||
error parsing 'goverter:map' at | ||
/ABSOLUTE/execution/input.go:6:5 | ||
func (github.com/jmattheis/goverter/execution.Converter).ConvertPerson(source github.com/jmattheis/goverter/execution.Person) github.com/jmattheis/goverter/execution.APIPerson | ||
missing target field |
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,19 @@ | ||
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: | ||
- hello=test | ||
error: invalid query type "hello" in query pattern "hello=test" |
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,94 @@ | ||
input: | ||
input.go: | | ||
package skip | ||
// goverter:converter | ||
type UsesGlobal interface { | ||
Enabled(*string) *string | ||
} | ||
// goverter:converter | ||
// goverter:skipCopySameType yes | ||
type KeepsGlobalValue interface { | ||
Enabled(*string) *string | ||
} | ||
// goverter:converter | ||
// goverter:skipCopySameType no | ||
type DisablesGlobal interface { | ||
Disabled(*int) *int | ||
} | ||
// goverter:converter | ||
// goverter:skipCopySameType no | ||
type EnableInSubMethod interface { | ||
Disable(*string) *string | ||
// goverter:skipCopySameType | ||
Enabled(*int) *int | ||
} | ||
// goverter:converter | ||
type DisableInSubMethod interface { | ||
Enabled(*string) *string | ||
// goverter:skipCopySameType no | ||
Disable(*int) *int | ||
} | ||
global: | ||
- skipCopySameType yes | ||
success: | ||
- generated/generated.go: | | ||
// Code generated by github.com/jmattheis/goverter, DO NOT EDIT. | ||
package generated | ||
type DisableInSubMethodImpl struct{} | ||
func (c *DisableInSubMethodImpl) Disable(source *int) *int { | ||
var pInt *int | ||
if source != nil { | ||
xint := *source | ||
pInt = &xint | ||
} | ||
return pInt | ||
} | ||
func (c *DisableInSubMethodImpl) Enabled(source *string) *string { | ||
return source | ||
} | ||
type DisablesGlobalImpl struct{} | ||
func (c *DisablesGlobalImpl) Disabled(source *int) *int { | ||
var pInt *int | ||
if source != nil { | ||
xint := *source | ||
pInt = &xint | ||
} | ||
return pInt | ||
} | ||
type EnableInSubMethodImpl struct{} | ||
func (c *EnableInSubMethodImpl) Disable(source *string) *string { | ||
var pString *string | ||
if source != nil { | ||
xstring := *source | ||
pString = &xstring | ||
} | ||
return pString | ||
} | ||
func (c *EnableInSubMethodImpl) Enabled(source *int) *int { | ||
return source | ||
} | ||
type KeepsGlobalValueImpl struct{} | ||
func (c *KeepsGlobalValueImpl) Enabled(source *string) *string { | ||
return source | ||
} | ||
type UsesGlobalImpl struct{} | ||
func (c *UsesGlobalImpl) Enabled(source *string) *string { | ||
return source | ||
} |