-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CASL-108 allowed table name length changed to 44
- Loading branch information
1 parent
484df12
commit d3df611
Showing
2 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
here-naksha-lib-model/src/commonTest/kotlin/naksha/model/NakshaTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package naksha.model | ||
|
||
import naksha.base.PlatformUtil.PlatformUtilCompanion.randomString | ||
import kotlin.test.Test | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertTrue | ||
|
||
class NakshaTest { | ||
|
||
@Test | ||
fun shouldLimitCollectionIdLength() { | ||
// expect | ||
var collectionId = collectionIdOf(1) | ||
assertTrue(collectionId) { Naksha.isValidId(collectionId) } | ||
collectionId = collectionIdOf(44) | ||
assertTrue(collectionId) { Naksha.isValidId(collectionId) } | ||
|
||
collectionId = collectionIdOf(45) | ||
assertFalse(collectionId) { Naksha.isValidId(collectionId) } | ||
assertFalse(collectionId) { Naksha.isValidId("") } | ||
} | ||
|
||
@Test | ||
fun shouldOnlyAllowCharacterAsFirstChar() { | ||
// expect | ||
assertTrue{ Naksha.isValidId("c1232_name") } | ||
assertFalse{ Naksha.isValidId("11232_name") } | ||
} | ||
|
||
@Test | ||
fun shouldNotAllowCapitalLettersOrUnsupportedCharacters() { | ||
// expect | ||
assertFalse{ Naksha.isValidId("C1232_name") } | ||
assertFalse{ Naksha.isValidId("name\$a") } | ||
assertFalse{ Naksha.isValidId("name&a") } | ||
assertFalse{ Naksha.isValidId("name*a") } | ||
assertFalse{ Naksha.isValidId("name#a") } | ||
assertFalse{ Naksha.isValidId("name@a") } | ||
assertFalse{ Naksha.isValidId("name!a") } | ||
|
||
assertTrue{ Naksha.isValidId("name_a") } | ||
assertTrue{ Naksha.isValidId("name-a") } | ||
assertTrue{ Naksha.isValidId("name:a") } | ||
} | ||
|
||
private fun collectionIdOf(length: Int): String = "c" + randomString(length - 1).lowercase() | ||
} |