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

	itr1 := createSpaceAndIteration(t, rest.db)
	assert.Equal(t, iteration.IterationStateNew, itr1.State)

	startState := iteration.IterationStateStart
	payload := app.UpdateIterationPayload{
		Data: &app.Iteration{
			Attributes: &app.IterationAttributes{
				State: &startState,
			},
			ID:   &itr1.ID,
			Type: iteration.APIStringTypeIteration,
		},
	}
	svc, ctrl := rest.SecuredController()
	_, updated := test.UpdateIterationOK(t, svc.Context, svc, ctrl, itr1.ID.String(), &payload)
	assert.Equal(t, startState, *updated.Data.Attributes.State)

	// create another iteration in same space and then change State to start
	itr2 := iteration.Iteration{
		Name:    "Spring 123",
		SpaceID: itr1.SpaceID,
	}
	err := rest.db.Iterations().Create(context.Background(), &itr2)
	require.Nil(t, err)
	payload2 := app.UpdateIterationPayload{
		Data: &app.Iteration{
			Attributes: &app.IterationAttributes{
				State: &startState,
			},
			ID:   &itr2.ID,
			Type: iteration.APIStringTypeIteration,
		},
	}
	test.UpdateIterationBadRequest(t, svc.Context, svc, ctrl, itr2.ID.String(), &payload2)

	// now close first iteration
	closeState := iteration.IterationStateClose
	payload.Data.Attributes.State = &closeState
	_, updated = test.UpdateIterationOK(t, svc.Context, svc, ctrl, itr1.ID.String(), &payload)
	assert.Equal(t, closeState, *updated.Data.Attributes.State)

	// try to start iteration 2 now
	_, updated2 := test.UpdateIterationOK(t, svc.Context, svc, ctrl, itr2.ID.String(), &payload2)
	assert.Equal(t, startState, *updated2.Data.Attributes.State)
}
Example #2
0
func (rest *TestIterationREST) TestSuccessUpdateIteration() {
	t := rest.T()
	resource.Require(t, resource.Database)

	itr := createSpaceAndIteration(t, rest.db)

	newName := "Sprint 1001"
	newDesc := "New Description"
	payload := app.UpdateIterationPayload{
		Data: &app.Iteration{
			Attributes: &app.IterationAttributes{
				Name:        &newName,
				Description: &newDesc,
			},
			ID:   &itr.ID,
			Type: iteration.APIStringTypeIteration,
		},
	}
	svc, ctrl := rest.SecuredController()
	_, updated := test.UpdateIterationOK(t, svc.Context, svc, ctrl, itr.ID.String(), &payload)
	assert.Equal(t, newName, *updated.Data.Attributes.Name)
	assert.Equal(t, newDesc, *updated.Data.Attributes.Description)
}