Skip to content

Commit ff289d5

Browse files
committed
tests
Signed-off-by: Julio Jimenez <julio@clickhouse.com>
1 parent 04d7500 commit ff289d5

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

test/simple.bats

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,45 @@ EOF
665665
[ "$status" -eq 1 ]
666666
[[ "$output" == *"Invalid email format"* ]]
667667
}
668+
669+
# Test 73: sanitize_email accepts valid name
670+
@test "sanitize_database_name accepts valid name" {
671+
run sanitize_database_name "test_database"
672+
[ "$status" -eq 0 ]
673+
[[ "$output" == "test_database" ]]
674+
}
675+
676+
# Test 74: sanitize_database_name accepts name with underscores
677+
@test "sanitize_database_name accepts name starting with underscore" {
678+
run sanitize_database_name "_test_database"
679+
[ "$status" -eq 0 ]
680+
[[ "$output" == "_test_database" ]]
681+
}
682+
683+
# Test 75: sanitize_database_name accepts name with numbers
684+
@test "sanitize_database_name accepts name with numbers" {
685+
run sanitize_database_name "test_database_123"
686+
[ "$status" -eq 0 ]
687+
[[ "$output" == "test_database_123" ]]
688+
}
689+
690+
# Test 76: sanitize_database_name removes dangerous characters
691+
@test "sanitize_database_name removes dangerous characters" {
692+
run sanitize_database_name "test-database.name"
693+
[ "$status" -eq 0 ]
694+
[[ "$output" == "testdatabasename" ]]
695+
}
696+
697+
# Test 77: sanitize_database_name rejects name with starting with number
698+
@test "sanitize_database_name rejects name starting with number" {
699+
run sanitize_database_name "1test_database"
700+
[ "$status" -eq 1 ]
701+
[[ "$output" == *"Invalid database name"* ]]
702+
}
703+
704+
# Test 78: sanitize_database_name rejects name with spaces
705+
@test "sanitize_database_name rejects name with spaces" {
706+
run sanitize_database_name "test database"
707+
[ "$status" -eq 1 ]
708+
[[ "$output" == *"Invalid database name"* ]]
709+
}

0 commit comments

Comments
 (0)