Documentation
¶
Overview ¶
Package let contains Common Testcase Variable Let declarations for testing purpose.
Index ¶
- func As[To, From any](Var testcase.Var[From]) testcase.Var[To]
- func Bool(s *testcase.Spec) testcase.Var[bool]
- func Contact(s *testcase.Spec, opts ...internal.ContactOption) testcase.Var[random.Contact]
- 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.ContactOption) 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 As ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/testcase/let"
)
func main() {
s := testcase.NewSpec((testing.TB)(nil))
type MyString string
str := let.As[MyString](let.String(s))
s.Test("", func(t *testcase.T) {
t.Log(str.Get(t))
})
}
func Bool ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func Context ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func ElementFrom ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func Email ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func Error ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func FirstName ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func Int ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func IntB ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func IntN ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func LastName ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func String ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func StringNC ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/testcase/let"
"go.llib.dev/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))
})
}
func Time ¶
Example ¶
package main
import (
"testing"
"time"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func TimeB ¶
Example ¶
package main
import (
"testing"
"time"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func UUID ¶
Example ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
func With ¶
Example (Func) ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
Example (TestcaseTFunc) ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
Example (TestingTBFunc) ¶
package main
import (
"testing"
"go.llib.dev/testcase"
"go.llib.dev/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))
})
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.