Tests[SendWithAdminKey, SendWithSendKey, SendWithReadKey, SendWithPermissionSendKey]

This commit is contained in:
2023-05-28 17:38:19 +02:00
parent dcb4f253d8
commit d4a8a2e720
4 changed files with 438 additions and 3 deletions

View File

@@ -177,6 +177,24 @@ func AssertTrue(t *testing.T, key string, v bool) {
}
}
func AssertNotDefault[T comparable](t *testing.T, key string, v T) {
if v == *new(T) {
t.Errorf("AssertNotDefault(%s) failed", key)
t.Error(ljson(v))
t.Error(string(debug.Stack()))
t.FailNow()
}
}
func AssertNotDefaultAny[T any](t *testing.T, key string, v T) {
if ljson(v) == ljson(*new(T)) {
t.Errorf("AssertNotDefault(%s) failed", key)
t.Error(ljson(v))
t.Error(string(debug.Stack()))
t.FailNow()
}
}
func AssertNotEqual(t *testing.T, key string, expected any, actual any) {
if expected == actual || (langext.IsNil(expected) && langext.IsNil(actual)) {
t.Errorf("Value [%s] does not differ (%T <-> %T):\n", key, expected, actual)

View File

@@ -546,6 +546,10 @@ func doAcceptSub(t *testing.T, baseUrl string, user Userdat, subscriber Userdat,
}
func LipsumWord(seed int64, wordcount int) string {
return loremipsum.NewWithSeed(seed).Words(wordcount)
}
func Lipsum(seed int64, paracount int) string {
return loremipsum.NewWithSeed(seed).Paragraphs(paracount)
}