jokes-bapak2/api/utils/random_test.go

27 lines
469 B
Go
Raw Normal View History

package utils_test
import (
2021-10-30 03:24:53 +00:00
"jokes-bapak2-api/utils"
"testing"
)
2021-08-04 05:56:14 +00:00
func TestRandomString_Valid(t *testing.T) {
random, err := utils.RandomString(10)
if err != nil {
t.Error(err)
}
if len(random) != 20 {
t.Error("result is not within the length of 10")
}
}
2021-08-04 05:56:14 +00:00
func TestRandomString_Invalid(t *testing.T) {
2021-08-04 10:05:58 +00:00
random, err := utils.RandomString(-10)
2021-08-04 05:56:14 +00:00
if err != nil {
t.Error(err)
}
if len(random) != 20 {
t.Error("result is not within the length of 10")
}
2021-08-04 09:03:53 +00:00
}