Browse Source

test case

Darien Raymond 8 năm trước cách đây
mục cha
commit
a624e50ffe
2 tập tin đã thay đổi với 12 bổ sung1 xóa
  1. 1 1
      app/proxyman/mux/session.go
  2. 11 0
      app/proxyman/mux/session_test.go

+ 1 - 1
app/proxyman/mux/session.go

@@ -78,7 +78,7 @@ func (m *SessionManager) CloseIfNoSession() bool {
 		return true
 	}
 
-	if len(m.sessions) > 0 {
+	if len(m.sessions) != 0 {
 		return false
 	}
 

+ 11 - 0
app/proxyman/mux/session_test.go

@@ -24,3 +24,14 @@ func TestSessionManagerAdd(t *testing.T) {
 	m.Add(s)
 	assert.Uint16(s.ID).Equals(4)
 }
+
+func TestSessionManagerClose(t *testing.T) {
+	assert := assert.On(t)
+
+	m := NewSessionManager()
+	s := m.Allocate()
+
+	assert.Bool(m.CloseIfNoSession()).IsFalse()
+	m.Remove(s.ID)
+	assert.Bool(m.CloseIfNoSession()).IsTrue()
+}