Example #1
0
func (rest *TestSpaceREST) TestSuccessUpdateProject() {
	t := rest.T()
	resource.Require(t, resource.Database)

	name := "Test 25"
	description := "Space for Test 25"
	newName := "Test 26"
	newDescription := "Space for Test 25"

	p := minimumRequiredCreateSpace()
	p.Data.Attributes.Name = &name
	p.Data.Attributes.Description = &description

	svc, ctrl := rest.SecuredController()
	_, created := test.CreateSpaceCreated(t, svc.Context, svc, ctrl, p)

	u := minimumRequiredUpdateSpace()
	u.Data.ID = created.Data.ID
	u.Data.Attributes.Version = created.Data.Attributes.Version
	u.Data.Attributes.Name = &newName
	u.Data.Attributes.Description = &newDescription

	_, updated := test.UpdateSpaceOK(t, svc.Context, svc, ctrl, created.Data.ID.String(), u)
	assert.Equal(t, newName, *updated.Data.Attributes.Name)
	assert.Equal(t, newDescription, *updated.Data.Attributes.Description)
}
Example #2
0
func (rest *TestSpaceREST) TestFailUpdateSpaceMissingName() {
	t := rest.T()
	resource.Require(t, resource.Database)

	name := "Test 25"

	p := minimumRequiredCreateSpace()
	p.Data.Attributes.Name = &name

	svc, ctrl := rest.SecuredController()
	_, created := test.CreateSpaceCreated(t, svc.Context, svc, ctrl, p)

	u := minimumRequiredUpdateSpace()
	u.Data.ID = created.Data.ID
	u.Data.Attributes.Version = created.Data.Attributes.Version

	test.UpdateSpaceBadRequest(t, svc.Context, svc, ctrl, created.Data.ID.String(), u)
}
Example #3
0
func (rest *TestSpaceREST) TestSuccessShowProject() {
	t := rest.T()
	resource.Require(t, resource.Database)

	name := "Test 27"
	description := "Space for Test 27"
	p := minimumRequiredCreateSpace()
	p.Data.Attributes.Name = &name
	p.Data.Attributes.Description = &description

	svc, ctrl := rest.SecuredController()
	_, created := test.CreateSpaceCreated(t, svc.Context, svc, ctrl, p)

	_, fetched := test.ShowSpaceOK(t, svc.Context, svc, ctrl, created.Data.ID.String())
	assert.Equal(t, created.Data.ID, fetched.Data.ID)
	assert.Equal(t, *created.Data.Attributes.Name, *fetched.Data.Attributes.Name)
	assert.Equal(t, *created.Data.Attributes.Description, *fetched.Data.Attributes.Description)
	assert.Equal(t, *created.Data.Attributes.Version, *fetched.Data.Attributes.Version)
}
Example #4
0
func (rest *TestSpaceREST) TestSuccessCreateSpace() {
	t := rest.T()
	resource.Require(t, resource.Database)

	name := "Test 24"

	p := minimumRequiredCreateSpace()
	p.Data.Attributes.Name = &name

	svc, ctrl := rest.SecuredController()
	_, created := test.CreateSpaceCreated(t, svc.Context, svc, ctrl, p)
	assert.NotNil(t, created.Data)
	assert.NotNil(t, created.Data.Attributes)
	assert.NotNil(t, created.Data.Attributes.CreatedAt)
	assert.NotNil(t, created.Data.Attributes.UpdatedAt)
	assert.NotNil(t, created.Data.Attributes.Name)
	assert.Equal(t, name, *created.Data.Attributes.Name)
	assert.NotNil(t, created.Data.Links)
	assert.NotNil(t, created.Data.Links.Self)
}
Example #5
0
func (rest *TestSpaceREST) TestSuccessListSpaces() {
	t := rest.T()
	resource.Require(t, resource.Database)

	name := "Test 24"

	p := minimumRequiredCreateSpace()
	p.Data.Attributes.Name = &name

	svc, ctrl := rest.SecuredController()
	test.CreateSpaceCreated(t, svc.Context, svc, ctrl, p)

	_, list := test.ListSpaceOK(t, svc.Context, svc, ctrl, nil, nil)
	assert.True(t, len(list.Data) > 0)
	for _, spc := range list.Data {
		subString := fmt.Sprintf("/%s/iterations", spc.ID.String())
		assert.Contains(t, *spc.Relationships.Iterations.Links.Related, subString)

		subStringAreaUrl := fmt.Sprintf("/%s/areas", spc.ID.String())
		assert.Contains(t, *spc.Relationships.Areas.Links.Related, subStringAreaUrl)
	}
}