Documentation
¶
Overview ¶
Package let contains Common Testcase Variable Let declarations for testing purpose.
Index ¶
- func Bool(s *testcase.Spec) testcase.Var[bool]
- func Context(s *testcase.Spec) testcase.Var[context.Context]
- func ElementFrom[V any](s *testcase.Spec, vs ...V) testcase.Var[V]
- func Email(s *testcase.Spec) testcase.Var[string]
- func Error(s *testcase.Spec) testcase.Var[error]
- func FirstName(s *testcase.Spec, opts ...internal.PersonOption) testcase.Var[string]
- func Int(s *testcase.Spec) testcase.Var[int]
- func IntB(s *testcase.Spec, min, max int) testcase.Var[int]
- func IntN(s *testcase.Spec, n int) testcase.Var[int]
- func LastName(s *testcase.Spec) testcase.Var[string]
- func String(s *testcase.Spec) testcase.Var[string]
- func StringNC(s *testcase.Spec, length int, charset string) testcase.Var[string]
- func Time(s *testcase.Spec) testcase.Var[time.Time]
- func TimeB(s *testcase.Spec, from, to time.Time) testcase.Var[time.Time]
- func UUID(s *testcase.Spec) testcase.Var[string]
- func With[V any, FN withFN[V]](s *testcase.Spec, fn FN) testcase.Var[V]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) b := let.Bool(s) s.Test("", func(t *testcase.T) { t.Log(b.Get(t)) }) }
Output:
func Context ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) ctx := let.Context(s) s.Test("", func(t *testcase.T) { t.Logf("%#v", ctx.Get(t)) }) }
Output:
func ElementFrom ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) v := let.ElementFrom(s, "foo", "bar", "baz") s.Test("", func(t *testcase.T) { t.Log(v.Get(t)) }) }
Output:
func Email ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) email := let.Email(s) s.Test("", func(t *testcase.T) { t.Log(email.Get(t)) }) }
Output:
func Error ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) expectedErr := let.Error(s) s.Test("", func(t *testcase.T) { t.Log(expectedErr.Get(t)) }) }
Output:
func FirstName ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) firstName := let.FirstName(s) s.Test("", func(t *testcase.T) { t.Log(firstName.Get(t)) }) }
Output:
func Int ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) n := let.Int(s) s.Test("", func(t *testcase.T) { t.Log(n.Get(t)) }) }
Output:
func IntB ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) n := let.IntB(s, 7, 42) s.Test("", func(t *testcase.T) { t.Log(n.Get(t)) }) }
Output:
func IntN ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) n := let.IntN(s, 42) s.Test("", func(t *testcase.T) { t.Log(n.Get(t)) }) }
Output:
func LastName ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) lastName := let.LastName(s) s.Test("", func(t *testcase.T) { t.Log(lastName.Get(t)) }) }
Output:
func String ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) str := let.String(s) s.Test("", func(t *testcase.T) { t.Log(str.Get(t)) }) }
Output:
func StringNC ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" "github.com/adamluzsi/testcase/random" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) str := let.StringNC(s, 42, random.CharsetASCII()) s.Test("", func(t *testcase.T) { t.Log(str.Get(t)) }) }
Output:
func Time ¶
Example ¶
package main import ( "testing" "time" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) tm := let.Time(s) s.Test("", func(t *testcase.T) { t.Log(tm.Get(t).Format(time.RFC3339)) }) }
Output:
func TimeB ¶
Example ¶
package main import ( "testing" "time" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) tm := let.TimeB(s, time.Now().AddDate(-1, 0, 0), time.Now()) s.Test("", func(t *testcase.T) { t.Log(tm.Get(t).Format(time.RFC3339)) }) }
Output:
func UUID ¶
Example ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) uuid := let.UUID(s) s.Test("", func(t *testcase.T) { t.Log(uuid.Get(t)) }) }
Output:
func With ¶
Example (Func) ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) v := let.With[int](s, func() int { return 42 }) s.Test("", func(t *testcase.T) { t.Log(v.Get(t)) }) }
Output:
Example (TestcaseTFunc) ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) v := let.With[int](s, func(t *testcase.T) int { return t.Random.Int() }) s.Test("", func(t *testcase.T) { t.Log(v.Get(t)) }) }
Output:
Example (TestingTBFunc) ¶
package main import ( "testing" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/let" ) func main() { s := testcase.NewSpec((testing.TB)(nil)) v := let.With[int](s, func(tb testing.TB) int { return 42 }) s.Test("", func(t *testcase.T) { t.Log(v.Get(t)) }) }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.