Initial commit: Custom Start Page application with authentication and DynamoDB storage
This commit is contained in:
55
internal/testing/helpers_test.go
Normal file
55
internal/testing/helpers_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/leanovate/gopter"
|
||||
"github.com/leanovate/gopter/gen"
|
||||
"github.com/leanovate/gopter/prop"
|
||||
)
|
||||
|
||||
func TestDefaultPropertyTestConfig(t *testing.T) {
|
||||
cfg := DefaultPropertyTestConfig()
|
||||
|
||||
if cfg.MinSuccessfulTests != 100 {
|
||||
t.Errorf("Expected MinSuccessfulTests to be 100, got %d", cfg.MinSuccessfulTests)
|
||||
}
|
||||
|
||||
if cfg.MaxSize != 100 {
|
||||
t.Errorf("Expected MaxSize to be 100, got %d", cfg.MaxSize)
|
||||
}
|
||||
|
||||
if cfg.Workers != 4 {
|
||||
t.Errorf("Expected Workers to be 4, got %d", cfg.Workers)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPropertyTest(t *testing.T) {
|
||||
// Simple property: for all integers, x + 0 = x
|
||||
RunPropertyTest(t, nil, func(properties *gopter.Properties) {
|
||||
properties.Property("addition identity", prop.ForAll(
|
||||
func(x int) bool {
|
||||
return x+0 == x
|
||||
},
|
||||
gen.Int(),
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
func TestRunPropertyTestWithCustomConfig(t *testing.T) {
|
||||
cfg := &PropertyTestConfig{
|
||||
MinSuccessfulTests: 50,
|
||||
MaxSize: 50,
|
||||
Workers: 2,
|
||||
}
|
||||
|
||||
// Simple property: for all strings, len(s) >= 0
|
||||
RunPropertyTest(t, cfg, func(properties *gopter.Properties) {
|
||||
properties.Property("string length non-negative", prop.ForAll(
|
||||
func(s string) bool {
|
||||
return len(s) >= 0
|
||||
},
|
||||
gen.AnyString(),
|
||||
))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user