예제 #1
0
func TestClientManagerLenWithoutNew(t *testing.T) {
	manager := apns2.ClientManager{
		MaxSize: 32,
		MaxAge:  5 * time.Minute,
		Factory: apns2.NewClient,
	}

	assert.Equal(t, 0, manager.Len())
}
예제 #2
0
func TestClientManagerAddWithoutNew(t *testing.T) {
	manager := apns2.ClientManager{
		MaxSize: 32,
		MaxAge:  5 * time.Minute,
		Factory: apns2.NewClient,
	}

	manager.Add(apns2.NewClient(mockCert()))
	assert.Equal(t, 1, manager.Len())
}
예제 #3
0
func TestClientManagerGetWithoutNew(t *testing.T) {
	manager := apns2.ClientManager{
		MaxSize: 32,
		MaxAge:  5 * time.Minute,
		Factory: apns2.NewClient,
	}

	c1 := manager.Get(mockCert())
	c2 := manager.Get(mockCert())
	v1 := reflect.ValueOf(c1)
	v2 := reflect.ValueOf(c2)
	assert.NotNil(t, c1)
	assert.Equal(t, v1.Pointer(), v2.Pointer())
	assert.Equal(t, 1, manager.Len())
}