func TestContainerUpdateStats(t *testing.T) {
	var handler *ctest.MockContainerHandler
	var ref info.ContainerReference

	driver := &stest.MockStorageDriver{}

	statsList := itest.GenerateRandomStats(1, 4, 1*time.Second)
	stats := statsList[0]

	cd := createContainerDataAndSetHandler(
		driver,
		func(h *ctest.MockContainerHandler) {
			h.On("GetStats").Return(
				stats,
				nil,
			)
			handler = h
			ref.Name = h.Name
		},
		t,
	)

	driver.On("AddStats", ref, stats).Return(nil)

	err := cd.updateStats()
	if err != nil {
		t.Fatal(err)
	}

	handler.AssertExpectations(t)
}
Esempio n. 2
0
func TestUpdateStats(t *testing.T) {
	statsList := itest.GenerateRandomStats(1, 4, 1*time.Second)
	stats := statsList[0]

	cd, mockHandler, mockDriver := newTestContainerData(t)
	mockHandler.On("GetStats").Return(
		stats,
		nil,
	)

	mockDriver.On("AddStats", info.ContainerReference{Name: mockHandler.Name}, stats).Return(nil)

	err := cd.updateStats()
	if err != nil {
		t.Fatal(err)
	}

	mockHandler.AssertExpectations(t)
}