浏览代码

add basic test cases for ALPN protocols

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
Nicola Murino 1 年之前
父节点
当前提交
9bcdc90ca8
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      internal/common/common_test.go

+ 11 - 0
internal/common/common_test.go

@@ -1750,6 +1750,17 @@ func TestSQLPlaceholderLimits(t *testing.T) {
 	}
 	}
 }
 }
 
 
+func TestALPNProtocols(t *testing.T) {
+	protocols := util.GetALPNProtocols(nil)
+	assert.Equal(t, []string{"http/1.1", "h2"}, protocols)
+	protocols = util.GetALPNProtocols([]string{"invalid1", "invalid2"})
+	assert.Equal(t, []string{"http/1.1", "h2"}, protocols)
+	protocols = util.GetALPNProtocols([]string{"invalid1", "h2", "invalid2"})
+	assert.Equal(t, []string{"h2"}, protocols)
+	protocols = util.GetALPNProtocols([]string{"h2", "http/1.1"})
+	assert.Equal(t, []string{"h2", "http/1.1"}, protocols)
+}
+
 func BenchmarkBcryptHashing(b *testing.B) {
 func BenchmarkBcryptHashing(b *testing.B) {
 	bcryptPassword := "bcryptpassword"
 	bcryptPassword := "bcryptpassword"
 	for i := 0; i < b.N; i++ {
 	for i := 0; i < b.N; i++ {