2021-08-03 18:15:35 +00:00
|
|
|
package utils_test
|
|
|
|
|
|
|
|
import (
|
2021-10-30 03:24:53 +00:00
|
|
|
"jokes-bapak2-api/utils"
|
2021-08-03 18:15:35 +00:00
|
|
|
"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-03 18:15:35 +00:00
|
|
|
}
|
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
|
|
|
}
|