Skip to content

Commit

Permalink
Merge pull request #36 from gone-io/feature/1.x
Browse files Browse the repository at this point in the history
feat: Export RunTest for testing
  • Loading branch information
Degfy authored Nov 6, 2024
2 parents 60763c1 + 612e26b commit d4ef5a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ func TimeStat(name string, start time.Time, logs ...func(format string, args ...
)
}

func testRun(fn any, priests ...Priest) {
func RunTest(fn any, priests ...Priest) {
Prepare(priests...).testKit().Run(fn)
}

// Test Use for writing test cases, refer to [example](https://github.com/gone-io/gone/blob/main/example/test/goner_test.go)
func Test[T Goner](fn func(goner T), priests ...Priest) {
testRun(func(in struct {
RunTest(func(in struct {
cemetery Cemetery `gone:"*"`
}) {
ft := reflect.TypeOf(fn)
Expand All @@ -214,7 +214,7 @@ func Test[T Goner](fn func(goner T), priests ...Priest) {

// TestAt Use for writing test cases, test a specific ID of Goner
func TestAt[T Goner](id GonerId, fn func(goner T), priests ...Priest) {
testRun(func(in struct {
RunTest(func(in struct {
cemetery Cemetery `gone:"*"`
}) {
theTomb := in.cemetery.GetTomById(id)
Expand Down
4 changes: 2 additions & 2 deletions tools/gone/mock/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func action(ctx *cli.Context) error {
return doAction(ctx.String("f"), ctx.String("o"))
}

func doAction(fromfile, outfile string) error {
func doAction(fromFile, outfile string) error {
err := os.MkdirAll(filepath.Dir(outfile), os.ModePerm)
if err != nil {
return err
Expand All @@ -46,7 +46,7 @@ func doAction(fromfile, outfile string) error {
if isInputFromPipe() {
return patchMock(os.Stdin, outFile)
} else {
file, e := getFile(fromfile)
file, e := getFile(fromFile)
if e != nil {
return e
}
Expand Down

0 comments on commit d4ef5a5

Please sign in to comment.