func (rest *TestSpaceIterationREST) TestSuccessCreateIterationWithOptionalValues() { t := rest.T() resource.Require(t, resource.Database) var p *space.Space iterationName := "Sprint #22" iterationDesc := "testing description" ci := createSpaceIteration(iterationName, &iterationDesc) application.Transactional(rest.db, func(app application.Application) error { repo := app.Spaces() testSpace := space.Space{ Name: "Test 1", } p, _ = repo.Create(context.Background(), &testSpace) return nil }) svc, ctrl := rest.SecuredController() _, c := test.CreateSpaceIterationsCreated(t, svc.Context, svc, ctrl, p.ID.String(), ci) assert.NotNil(t, c.Data.ID) assert.NotNil(t, c.Data.Relationships.Space) assert.Equal(t, p.ID.String(), *c.Data.Relationships.Space.Data.ID) assert.Equal(t, *c.Data.Attributes.Name, iterationName) assert.Equal(t, *c.Data.Attributes.Description, iterationDesc) // create another Iteration with nil description iterationName2 := "Sprint #23" ci = createSpaceIteration(iterationName2, nil) _, c = test.CreateSpaceIterationsCreated(t, svc.Context, svc, ctrl, p.ID.String(), ci) assert.Equal(t, *c.Data.Attributes.Name, iterationName2) assert.Nil(t, c.Data.Attributes.Description) }
func (rest *TestSpaceIterationREST) TestSuccessCreateIteration() { t := rest.T() resource.Require(t, resource.Database) var p *space.Space ci := createSpaceIteration("Sprint #21", nil) application.Transactional(rest.db, func(app application.Application) error { repo := app.Spaces() newSpace := space.Space{ Name: "Test 1", } p, _ = repo.Create(context.Background(), &newSpace) return nil }) svc, ctrl := rest.SecuredController() _, c := test.CreateSpaceIterationsCreated(t, svc.Context, svc, ctrl, p.ID.String(), ci) require.NotNil(t, c.Data.ID) require.NotNil(t, c.Data.Relationships.Space) assert.Equal(t, p.ID.String(), *c.Data.Relationships.Space.Data.ID) assert.Equal(t, iteration.IterationStateNew, *c.Data.Attributes.State) }