コード例 #1
0
func TestDao_UpdateResourcePool(t *testing.T) {
	controlPlaneDao.RemoveResourcePool("default", &unused)

	pool, _ := dao.NewResourcePool("default")
	controlPlaneDao.AddResourcePool(*pool, &id)

	pool.Priority = 1
	pool.CoreLimit = 1
	pool.MemoryLimit = 1
	err := controlPlaneDao.UpdateResourcePool(*pool, &unused)

	if err != nil {
		t.Errorf("Failure updating resource pool %-v with error: %s", pool, err)
		t.Fail()
	}

	result := dao.ResourcePool{}
	controlPlaneDao.GetResourcePool("default", &result)
	result.CreatedAt = pool.CreatedAt
	result.UpdatedAt = pool.UpdatedAt
	if *pool != result {
		t.Errorf("%+v != %+v", *pool, result)
		t.Fail()
	}
}
コード例 #2
0
func TestDao_GetResourcePool(t *testing.T) {
	controlPlaneDao.RemoveResourcePool("default", &unused)
	pool, _ := dao.NewResourcePool("default")
	pool.Priority = 1
	pool.CoreLimit = 1
	pool.MemoryLimit = 1
	controlPlaneDao.AddResourcePool(*pool, &id)

	result := dao.ResourcePool{}
	err := controlPlaneDao.GetResourcePool("default", &result)
	result.CreatedAt = pool.CreatedAt
	result.UpdatedAt = pool.UpdatedAt
	if err == nil {
		if *pool != result {
			t.Errorf("Unexpected ResourcePool: expected=%+v, actual=%+v", pool, result)
		}
	} else {
		t.Errorf("Unexpected Error Retrieving ResourcePool: err=%s", err)
	}
}
コード例 #3
0
func TestDao_GetResourcePools(t *testing.T) {
	controlPlaneDao.RemoveResourcePool("default", &unused)

	pool, _ := dao.NewResourcePool("default")
	pool.Priority = 1
	pool.CoreLimit = 2
	pool.MemoryLimit = 3
	controlPlaneDao.AddResourcePool(*pool, &id)

	var result map[string]*dao.ResourcePool
	err := controlPlaneDao.GetResourcePools(new(dao.EntityRequest), &result)
	if err == nil && len(result) == 1 {
		result["default"].CreatedAt = pool.CreatedAt
		result["default"].UpdatedAt = pool.UpdatedAt
		if *result["default"] != *pool {
			t.Errorf("expected [%+v] actual=%s", *pool, result)
			t.Fail()
		}
	} else {
		t.Errorf("Unexpected Error Retrieving ResourcePools: err=%s", result)
		t.Fail()
	}
}