// TestGetCountsPerIteration makes sure that the query being executed is correctly returning
// the counts of work items
TestGetCountsPerIteration makes sure that the query being executed is correctly returning
the counts of work items
// TestGetCountsPerIteration makes sure that the query being executed is correctly returning // the counts of work items
func (s *workItemRepoBlackBoxTest) TestGetCountsPerIteration() {
	spaceRepo := space.NewRepository(s.DB)
	spaceInstance := space.Space{
		Name: "Testing space" + uuid.NewV4().String(),
	}
	spaceRepo.Create(s.ctx, &spaceInstance)
	assert.NotEqual(s.T(), uuid.UUID{}, spaceInstance.ID)
	iterationRepo := iteration.NewIterationRepository(s.DB)
	iteration1 := iteration.Iteration{
		Name:    "Sprint 1",
		SpaceID: spaceInstance.ID,
	}
	err := iterationRepo.Create(s.ctx, &iteration1)
	require.Nil(s.T(), err)
	s.T().Log("iteration1 id = ", iteration1.ID)
	assert.NotEqual(s.T(), uuid.UUID{}, iteration1.ID)
	iteration2 := iteration.Iteration{
		Name:    "Sprint 2",
		SpaceID: spaceInstance.ID,
	}
	err = iterationRepo.Create(s.ctx, &iteration2)
	require.Nil(s.T(), err)
	s.T().Log("iteration2 id = ", iteration2.ID)
	assert.NotEqual(s.T(), uuid.UUID{}, iteration2.ID)
	for i := 0; i < 3; i++ {
		_, err = s.repo.Create(
			s.ctx, spaceInstance.ID, workitem.SystemBug,
			map[string]interface{}{
				workitem.SystemTitle:     fmt.Sprintf("New issue #%d", i),
				workitem.SystemState:     workitem.SystemStateNew,
				workitem.SystemIteration: iteration1.ID.String(),
			}, s.creatorID)
		require.Nil(s.T(), err)
	}
	for i := 0; i < 2; i++ {
		_, err = s.repo.Create(
			s.ctx, spaceInstance.ID, workitem.SystemBug,
			map[string]interface{}{
				workitem.SystemTitle:     fmt.Sprintf("Closed issue #%d", i),
				workitem.SystemState:     workitem.SystemStateClosed,
				workitem.SystemIteration: iteration1.ID.String(),
			}, s.creatorID)
		require.Nil(s.T(), err)
	}
	countsMap, _ := s.repo.GetCountsPerIteration(s.ctx, spaceInstance.ID)
	require.Len(s.T(), countsMap, 1)
	require.Contains(s.T(), countsMap, iteration1.ID.String())
	assert.Equal(s.T(), 5, countsMap[iteration1.ID.String()].Total)
	assert.Equal(s.T(), 2, countsMap[iteration1.ID.String()].Closed)
}
func ( s * workItemRepoBlackBoxTest ) TestGetCountsPerIteration ( ) { spaceRepo := space . NewRepository ( s . DB ) spaceInstance := space . Space { Name : " " + uuid . NewV4 ( ) . String ( ) , } spaceRepo . Create ( s . ctx , & spaceInstance ) assert . NotEqual ( s . T ( ) , uuid . UUID { } , spaceInstance . ID ) iterationRepo := iteration . NewIterationRepository ( s . DB ) iteration1 := iteration . Iteration { Name : " " , SpaceID : spaceInstance . ID , } err := iterationRepo . Create ( s . ctx , & iteration1 ) require . Nil ( s . T ( ) , err ) s . T ( ) . Log ( " " , iteration1 . ID ) assert . NotEqual ( s . T ( ) , uuid . UUID { } , iteration1 . ID ) iteration2 := iteration . Iteration { Name : " " , SpaceID : spaceInstance . ID , } err = iterationRepo . Create ( s . ctx , & iteration2 ) require . Nil ( s . T ( ) , err ) s . T ( ) . Log ( " " , iteration2 . ID ) assert . NotEqual ( s . T ( ) , uuid . UUID { } , iteration2 . ID ) for i := 0 ; i < 3 ; i ++ { _ , err = s . repo . Create ( s . ctx , spaceInstance . ID , workitem . SystemBug , map [ string ] interface { } { workitem . SystemTitle : fmt . Sprintf ( " " , i ) , workitem . SystemState : workitem . SystemStateNew , workitem . SystemIteration : iteration1 . ID . String ( ) , } , s . creatorID ) require . Nil ( s . T ( ) , err ) } for i := 0 ; i < 2 ; i ++ { _ , err = s . repo . Create ( s . ctx , spaceInstance . ID , workitem . SystemBug , map [ string ] interface { } { workitem . SystemTitle : fmt . Sprintf ( " " , i ) , workitem . SystemState : workitem . SystemStateClosed , workitem . SystemIteration : iteration1 . ID . String ( ) , } , s . creatorID ) require . Nil ( s . T ( ) , err ) } countsMap , _ := s . repo . GetCountsPerIteration ( s . ctx , spaceInstance . ID ) require . Len ( s . T ( ) , countsMap , 1 ) require . Contains ( s . T ( ) , countsMap , iteration1 . ID . String ( ) ) assert . Equal ( s . T ( ) , 5 , countsMap [ iteration1 . ID . String ( ) ] . Total ) assert . Equal ( s . T ( ) , 2 , countsMap [ iteration1 . ID . String ( ) ] . Closed ) }
TestGetCountsPerIteration makes sure that the query being executed is correctly returning
the counts of work items
TestGetCountsPerIteration makes sure that the query being executed is correctly returning the counts of work items
// create seed data // given // when // then // given // when // then // given // when // then