summaryrefslogtreecommitdiffstats
path: root/models/topic_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/topic_test.go')
-rw-r--r--models/topic_test.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/topic_test.go b/models/topic_test.go
index 472f4e52d9..ef374e557b 100644
--- a/models/topic_test.go
+++ b/models/topic_test.go
@@ -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"))
+}