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

	service, _ := dao.NewService()
	service.Id = "default"
	controlPlaneDao.AddService(*service, &id)

	service.Name = "name"
	err := controlPlaneDao.UpdateService(*service, &unused)
	if err != nil {
		t.Errorf("Failure updating service %-v with error: %s", service, err)
		t.Fail()
	}

	result := dao.Service{}
	controlPlaneDao.GetService("default", &result)
	//XXX the time.Time types fail comparison despite being equal...
	//    as far as I can tell this is a limitation with Go
	result.UpdatedAt = service.UpdatedAt
	result.CreatedAt = service.CreatedAt
	if !service.Equals(&result) {
		t.Errorf("Expected Service %+v, Actual Service %+v", result, *service)
		t.Fail()
	}
}
コード例 #2
0
func TestDao_GetService(t *testing.T) {
	controlPlaneDao.RemoveService("default", &unused)

	service, _ := dao.NewService()
	service.Id = "default"
	controlPlaneDao.AddService(*service, &id)

	var result dao.Service
	err := controlPlaneDao.GetService("default", &result)
	//XXX the time.Time types fail comparison despite being equal...
	//    as far as I can tell this is a limitation with Go
	result.UpdatedAt = service.UpdatedAt
	result.CreatedAt = service.CreatedAt
	if err == nil {
		if !service.Equals(&result) {
			t.Errorf("GetService Failed: expected=%+v, actual=%+v", service, result)
		}
	} else {
		t.Errorf("Unexpected Error Retrieving Service: err=%s", err)
	}
}