func (s *workItemChildSuite) SetupTest() {
	s.clean = cleaner.DeleteCreatedEntities(s.DB)
	var err error

	// Create a test user identity
	priv, err := almtoken.ParsePrivateKey([]byte(almtoken.RSAPrivateKey))
	require.Nil(s.T(), err)
	testIdentity, err := testsupport.CreateTestIdentity(s.DB, "test user", "test provider")
	require.Nil(s.T(), err)
	s.svc = testsupport.ServiceAsUser("TestWorkItem-Service", almtoken.NewManagerWithPrivateKey(priv), testIdentity)
	require.NotNil(s.T(), s.svc)

	// Create a work item link space
	createSpacePayload := CreateSpacePayload("test-space"+uuid.NewV4().String(), "description")
	_, space := test.CreateSpaceCreated(s.T(), s.svc.Context, s.svc, s.spaceCtrl, createSpacePayload)
	s.userSpaceID = *space.Data.ID
	s.T().Logf("Created link space with ID: %s\n", *space.Data.ID)

	// Create 3 work items (bug1, bug2, and bug3)
	bug1Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug1")
	_, bug1 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug1Payload)
	require.NotNil(s.T(), bug1)

	s.bug1 = bug1
	s.bug1ID, err = strconv.ParseUint(*bug1.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug1 with ID: %s\n", *bug1.Data.ID)

	bug2Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug2")
	_, bug2 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug2Payload)
	require.NotNil(s.T(), bug2)

	bug2ID, err := strconv.ParseUint(*bug2.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug2 with ID: %s\n", *bug2.Data.ID)

	bug3Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug3")
	_, bug3 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug3Payload)
	require.NotNil(s.T(), bug3)

	s.bug3 = bug3
	bug3ID, err := strconv.ParseUint(*bug3.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug3 with ID: %s\n", *bug3.Data.ID)

	// Create a work item link category
	createLinkCategoryPayload := CreateWorkItemLinkCategory("test-user" + uuid.NewV4().String())
	_, workItemLinkCategory := test.CreateWorkItemLinkCategoryCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCategoryCtrl, createLinkCategoryPayload)
	require.NotNil(s.T(), workItemLinkCategory)
	userLinkCategoryID := *workItemLinkCategory.Data.ID
	s.T().Logf("Created link category with ID: %s\n", *workItemLinkCategory.Data.ID)

	// Create work item link type payload
	createLinkTypePayload := createParentChildWorkItemLinkType("test-bug-blocker", workitem.SystemBug, workitem.SystemBug, userLinkCategoryID, s.userSpaceID)
	_, workItemLinkType := test.CreateWorkItemLinkTypeCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkTypeCtrl, s.userSpaceID.String(), createLinkTypePayload)
	require.NotNil(s.T(), workItemLinkType)
	bugBlockerLinkTypeID := *workItemLinkType.Data.ID
	s.T().Logf("Created link type with ID: %s\n", *workItemLinkType.Data.ID)

	createPayload := CreateWorkItemLink(s.bug1ID, bug2ID, bugBlockerLinkTypeID)
	_, workItemLink := test.CreateWorkItemLinkCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCtrl, createPayload)
	require.NotNil(s.T(), workItemLink)

	createPayload2 := CreateWorkItemLink(s.bug1ID, bug3ID, bugBlockerLinkTypeID)
	_, workItemLink2 := test.CreateWorkItemLinkCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCtrl, createPayload2)
	require.NotNil(s.T(), workItemLink2)
}
// The SetupTest method will be run before every test in the suite.
// SetupTest ensures that none of the work item links that we will create already exist.
// It will also make sure that some resources that we rely on do exists.
The SetupTest method will be run before every test in the suite.
SetupTest ensures that none of the work item links that we will create already exist.
It will also make sure that some resources that we rely on do exists.
// The SetupTest method will be run before every test in the suite . // SetupTest ensures that none of the work item links that we will create already exist . // It will also make sure that some resources that we rely on do exists .
func (s *workItemChildSuite) SetupTest() {
	s.clean = cleaner.DeleteCreatedEntities(s.DB)
	var err error
	priv, err := almtoken.ParsePrivateKey([]byte(almtoken.RSAPrivateKey))
	require.Nil(s.T(), err)
	testIdentity, err := testsupport.CreateTestIdentity(s.DB, "test user", "test provider")
	require.Nil(s.T(), err)
	s.svc = testsupport.ServiceAsUser("TestWorkItem-Service", almtoken.NewManagerWithPrivateKey(priv), testIdentity)
	require.NotNil(s.T(), s.svc)
	createSpacePayload := CreateSpacePayload("test-space"+uuid.NewV4().String(), "description")
	_, space := test.CreateSpaceCreated(s.T(), s.svc.Context, s.svc, s.spaceCtrl, createSpacePayload)
	s.userSpaceID = *space.Data.ID
	s.T().Logf("Created link space with ID: %s\n", *space.Data.ID)
	bug1Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug1")
	_, bug1 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug1Payload)
	require.NotNil(s.T(), bug1)
	s.bug1 = bug1
	s.bug1ID, err = strconv.ParseUint(*bug1.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug1 with ID: %s\n", *bug1.Data.ID)
	bug2Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug2")
	_, bug2 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug2Payload)
	require.NotNil(s.T(), bug2)
	bug2ID, err := strconv.ParseUint(*bug2.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug2 with ID: %s\n", *bug2.Data.ID)
	bug3Payload := CreateWorkItem(s.userSpaceID, workitem.SystemBug, "bug3")
	_, bug3 := test.CreateWorkitemCreated(s.T(), s.svc.Context, s.svc, s.workItemCtrl, s.userSpaceID.String(), bug3Payload)
	require.NotNil(s.T(), bug3)
	s.bug3 = bug3
	bug3ID, err := strconv.ParseUint(*bug3.Data.ID, 10, 64)
	require.Nil(s.T(), err)
	s.T().Logf("Created bug3 with ID: %s\n", *bug3.Data.ID)
	createLinkCategoryPayload := CreateWorkItemLinkCategory("test-user" + uuid.NewV4().String())
	_, workItemLinkCategory := test.CreateWorkItemLinkCategoryCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCategoryCtrl, createLinkCategoryPayload)
	require.NotNil(s.T(), workItemLinkCategory)
	userLinkCategoryID := *workItemLinkCategory.Data.ID
	s.T().Logf("Created link category with ID: %s\n", *workItemLinkCategory.Data.ID)
	createLinkTypePayload := createParentChildWorkItemLinkType("test-bug-blocker", workitem.SystemBug, workitem.SystemBug, userLinkCategoryID, s.userSpaceID)
	_, workItemLinkType := test.CreateWorkItemLinkTypeCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkTypeCtrl, s.userSpaceID.String(), createLinkTypePayload)
	require.NotNil(s.T(), workItemLinkType)
	bugBlockerLinkTypeID := *workItemLinkType.Data.ID
	s.T().Logf("Created link type with ID: %s\n", *workItemLinkType.Data.ID)
	createPayload := CreateWorkItemLink(s.bug1ID, bug2ID, bugBlockerLinkTypeID)
	_, workItemLink := test.CreateWorkItemLinkCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCtrl, createPayload)
	require.NotNil(s.T(), workItemLink)
	createPayload2 := CreateWorkItemLink(s.bug1ID, bug3ID, bugBlockerLinkTypeID)
	_, workItemLink2 := test.CreateWorkItemLinkCreated(s.T(), s.svc.Context, s.svc, s.workItemLinkCtrl, createPayload2)
	require.NotNil(s.T(), workItemLink2)
}
func ( s * workItemChildSuite ) SetupTest ( ) { s . clean = cleaner . DeleteCreatedEntities ( s . DB ) var err error priv , err := almtoken . ParsePrivateKey ( [ ] byte ( almtoken . RSAPrivateKey ) ) require . Nil ( s . T ( ) , err ) testIdentity , err := testsupport . CreateTestIdentity ( s . DB , " " , " " ) require . Nil ( s . T ( ) , err ) s . svc = testsupport . ServiceAsUser ( " " , almtoken . NewManagerWithPrivateKey ( priv ) , testIdentity ) require . NotNil ( s . T ( ) , s . svc ) createSpacePayload := CreateSpacePayload ( " " + uuid . NewV4 ( ) . String ( ) , " " ) _ , space := test . CreateSpaceCreated ( s . T ( ) , s . svc . Context , s . svc , s . spaceCtrl , createSpacePayload ) s . userSpaceID = * space . Data . ID s . T ( ) . Logf ( " \n " , * space . Data . ID ) bug1Payload := CreateWorkItem ( s . userSpaceID , workitem . SystemBug , " " ) _ , bug1 := test . CreateWorkitemCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemCtrl , s . userSpaceID . String ( ) , bug1Payload ) require . NotNil ( s . T ( ) , bug1 ) s . bug1 = bug1 s . bug1ID , err = strconv . ParseUint ( * bug1 . Data . ID , 10 , 64 ) require . Nil ( s . T ( ) , err ) s . T ( ) . Logf ( " \n " , * bug1 . Data . ID ) bug2Payload := CreateWorkItem ( s . userSpaceID , workitem . SystemBug , " " ) _ , bug2 := test . CreateWorkitemCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemCtrl , s . userSpaceID . String ( ) , bug2Payload ) require . NotNil ( s . T ( ) , bug2 ) bug2ID , err := strconv . ParseUint ( * bug2 . Data . ID , 10 , 64 ) require . Nil ( s . T ( ) , err ) s . T ( ) . Logf ( " \n " , * bug2 . Data . ID ) bug3Payload := CreateWorkItem ( s . userSpaceID , workitem . SystemBug , " " ) _ , bug3 := test . CreateWorkitemCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemCtrl , s . userSpaceID . String ( ) , bug3Payload ) require . NotNil ( s . T ( ) , bug3 ) s . bug3 = bug3 bug3ID , err := strconv . ParseUint ( * bug3 . Data . ID , 10 , 64 ) require . Nil ( s . T ( ) , err ) s . T ( ) . Logf ( " \n " , * bug3 . Data . ID ) createLinkCategoryPayload := CreateWorkItemLinkCategory ( " " + uuid . NewV4 ( ) . String ( ) ) _ , workItemLinkCategory := test . CreateWorkItemLinkCategoryCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemLinkCategoryCtrl , createLinkCategoryPayload ) require . NotNil ( s . T ( ) , workItemLinkCategory ) userLinkCategoryID := * workItemLinkCategory . Data . ID s . T ( ) . Logf ( " \n " , * workItemLinkCategory . Data . ID ) createLinkTypePayload := createParentChildWorkItemLinkType ( " " , workitem . SystemBug , workitem . SystemBug , userLinkCategoryID , s . userSpaceID ) _ , workItemLinkType := test . CreateWorkItemLinkTypeCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemLinkTypeCtrl , s . userSpaceID . String ( ) , createLinkTypePayload ) require . NotNil ( s . T ( ) , workItemLinkType ) bugBlockerLinkTypeID := * workItemLinkType . Data . ID s . T ( ) . Logf ( " \n " , * workItemLinkType . Data . ID ) createPayload := CreateWorkItemLink ( s . bug1ID , bug2ID , bugBlockerLinkTypeID ) _ , workItemLink := test . CreateWorkItemLinkCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemLinkCtrl , createPayload ) require . NotNil ( s . T ( ) , workItemLink ) createPayload2 := CreateWorkItemLink ( s . bug1ID , bug3ID , bugBlockerLinkTypeID ) _ , workItemLink2 := test . CreateWorkItemLinkCreated ( s . T ( ) , s . svc . Context , s . svc , s . workItemLinkCtrl , createPayload2 ) require . NotNil ( s . T ( ) , workItemLink2 ) }
The SetupTest method will be run before every test in the suite.
The SetupTest method will be run before every test in the suite .
// Create a test user identity // Create a work item link space // Create 3 work items (bug1, bug2, and bug3) // Create a work item link category // Create work item link type payload