Skip to content

Commit

Permalink
README: fix signature for SequenceField function argument (nauyey#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ABorovenskyi authored and nauyey committed Nov 20, 2018
1 parent a3bf873 commit b617f02
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type User struct {

// Define a factory for User struct
userFactory := def.NewFactory(User{}, "db_table_users",
def.SequenceField("ID", 1, func(n int64) interface{} {
return n
def.SequenceField("ID", 1, func(n int64) (interface{}, error) {
return n, nil
}),
def.DynamicField("Name", func(user interface{}) (interface{}, error) {
return fmt.Sprintf("User Name %d", user.(*User).ID), nil
Expand Down Expand Up @@ -118,8 +118,8 @@ type User struct {
// This will define a factory for User struct
userFactory := def.NewFactory(User{}, "",
def.Field("Name", "test name"),
def.SequenceField("ID", 0, func(n int64) interface{} {
return n
def.SequenceField("ID", 0, func(n int64) (interface{}, error) {
return n, nil
}),
def.Trait("Chinese",
def.Field("Country", "china"),
Expand All @@ -142,8 +142,8 @@ type UserForSave struct {
// This will define a factory for UserForSave struct with database table
userForSaveFactory := def.NewFactory(UserForSave{}, "model_table",
def.Field("Name", "test name"),
def.SequenceField("ID", 0, func(n int64) interface{} {
return n
def.SequenceField("ID", 0, func(n int64) (interface{}, error) {
return n, nil
}),
def.Trait("Chinese",
def.Field("Country", "china"),
Expand Down Expand Up @@ -300,8 +300,8 @@ import (

// Defines a new sequence field
userFactory := def.NewFactory(User{}, "model_table",
def.SequenceField("Email", 0, func(n int64) interface{} {
return fmt.Sprintf("person%d@example.com", n)
def.SequenceField("Email", 0, func(n int64) (interface{}, error) {
return fmt.Sprintf("person%d@example.com", n), nil
}),
)

Expand All @@ -318,8 +318,8 @@ You can also set the initial start of the sequence:

```golang
userFactory := def.NewFactory(User{}, "model_table",
def.SequenceField("Email", 1000, func(n int64) interface{} {
return fmt.Sprintf("person%d@example.com", n)
def.SequenceField("Email", 1000, func(n int64) (interface{}, error) {
return fmt.Sprintf("person%d@example.com", n), nil
}),
)

Expand Down Expand Up @@ -404,8 +404,8 @@ type Blog struct {
}

blogFactory := def.NewFactory(Blog{}, "blog_table",
def.SequenceField("ID", 1, func(n int64) interface{} {
return n
def.SequenceField("ID", 1, func(n int64) (interface{}, error) {
return n, nil
}),
)

Expand Down

0 comments on commit b617f02

Please sign in to comment.