- available, created := writerPool.Stats()
- assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
- writerPool.Close()
-}
-
-func TestClose(t *testing.T) {
- writerPool = nil
- instanceMock := initSdlInstanceMock(namespace, 2)
- w1 := GetRNibWriter()
- w2 := GetRNibWriter()
- writerPool.Put(w1)
- writerPool.Put(w2)
- available, created := writerPool.Stats()
- assert.Equal(t, 2, available, "number of available objects in the writerPool should be 2")
- assert.Equal(t, 2, created, "number of created objects in the writerPool should be 2")
- var e error
- instanceMock.On("Close").Return(e)
- Close()
- available, created = writerPool.Stats()
- assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
-}
-
-func TestCloseOnClosedPoolFailure(t *testing.T) {
- writerPool = nil
- instanceMock := initSdlInstanceMock(namespace, 1)
- w1 := GetRNibWriter()
- writerPool.Put(w1)
- available, created := writerPool.Stats()
- assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
- var e error
- instanceMock.On("Close").Return(e)
- Close()
- assert.Panics(t, func(){Close()})
-}
-
-func TestCloseFailure(t *testing.T) {
- writerPool = nil
- instanceMock := initSdlInstanceMock(namespace, 2)
- w1 := GetRNibWriter()
- writerPool.Put(w1)
- available, created := writerPool.Stats()
- assert.Equal(t, 1, available, "number of available objects in the writerPool should be 1")
- assert.Equal(t, 1, created, "number of created objects in the writerPool should be 1")
- e := errors.New("expected error")
- instanceMock.On("Close").Return(e)
- Close()
- available, created = writerPool.Stats()
- assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")
-}
-
-func TestInit(t *testing.T) {
- writerPool = nil
- Init("", 1)
- assert.NotNil(t, writerPool)
- assert.NotNil(t, writerPool.New)
- assert.NotNil(t, writerPool.Destroy)
- available, created := writerPool.Stats()
- assert.Equal(t, 0, available, "number of available objects in the writerPool should be 0")
- assert.Equal(t, 0, created, "number of created objects in the writerPool should be 0")