mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-16 11:00:02 +02:00
* Added topics validation, fixed repo topics duplication (#4031) Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Added tests Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Fixed fmt Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Added comments to exported functions Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Deleted RemoveDuplicateTopics function Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Fixed messages Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Added migration Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * fmt migration file Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * fixed lint Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Added Copyright Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Added query solution for duplicates Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Fixed migration query Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Changed RegExp. Fixed migration Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * fmt migration file Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Fixed test for changed regexp Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Removed validation log messages Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Renamed migration file Signed-off-by: Alexey Terentyev <axifnx@gmail.com> * Renamed validate function Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
This commit is contained in:
parent
9ae7664df7
commit
46d19c4676
8 changed files with 229 additions and 4 deletions
|
@ -55,3 +55,16 @@ func TestAddTopic(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 2, len(topics))
|
||||
}
|
||||
|
||||
func TestTopicValidator(t *testing.T) {
|
||||
assert.True(t, ValidateTopic("12345"))
|
||||
assert.True(t, ValidateTopic("2-test"))
|
||||
assert.True(t, ValidateTopic("test-3"))
|
||||
assert.True(t, ValidateTopic("first"))
|
||||
assert.True(t, ValidateTopic("second-test-topic"))
|
||||
assert.True(t, ValidateTopic("third-project-topic-with-max-length"))
|
||||
|
||||
assert.False(t, ValidateTopic("$fourth-test,topic"))
|
||||
assert.False(t, ValidateTopic("-fifth-test-topic"))
|
||||
assert.False(t, ValidateTopic("sixth-go-project-topic-with-excess-length"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue