test: add an unit test for generate()
This commit is contained in:
@@ -1 +1,26 @@
|
|||||||
|
import gleam/list
|
||||||
|
import gleam/string
|
||||||
|
import gleeunit
|
||||||
|
import gleeunit/should
|
||||||
|
import key
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
gleeunit.main()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn generate_test() {
|
||||||
|
let key_result = key.generate()
|
||||||
|
let allowed_chars =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||||
|
|
||||||
|
key_result |> should.not_equal("")
|
||||||
|
|
||||||
|
key_result
|
||||||
|
|> string.length
|
||||||
|
|> should.equal(16)
|
||||||
|
|
||||||
|
key_result
|
||||||
|
|> string.to_graphemes
|
||||||
|
|> list.all(fn(char) { allowed_chars |> string.contains(char) })
|
||||||
|
|> should.be_true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user