예제 #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_NewResourcePool(t *testing.T) {
	controlPlaneDao.RemoveResourcePool("default", &unused)
	pool := dao.ResourcePool{}
	err := controlPlaneDao.AddResourcePool(pool, &id)
	if err == nil {
		t.Errorf("Expected failure to create resource pool %-v", pool)
		t.Fail()
	}

	pool.Id = "default"
	err = controlPlaneDao.AddResourcePool(pool, &id)
	if err != nil {
		t.Errorf("Failure creating resource pool %-v with error: %s", pool, err)
		t.Fail()
	}

	err = controlPlaneDao.AddResourcePool(pool, &id)
	if err == nil {
		t.Errorf("Expected error creating redundant resource pool %-v", pool)
		t.Fail()
	}
}