// TestShowWorkItemLinkOK tests if we can fetch the "system" work item link
func (s *workItemLinkSuite) TestShowWorkItemLinkOK() {
	createPayload := CreateWorkItemLink(s.bug1ID, s.bug2ID, s.bugBlockerLinkTypeID)
	_, workItemLink := test.CreateWorkItemLinkCreated(s.T(), nil, nil, s.workItemLinkCtrl, createPayload)
	require.NotNil(s.T(), workItemLink)
	// Delete this work item link during cleanup
	s.deleteWorkItemLinks = append(s.deleteWorkItemLinks, *workItemLink.Data.ID)
	expected := link.WorkItemLink{}
	require.Nil(s.T(), link.ConvertLinkToModel(*workItemLink, &expected))

	_, readIn := test.ShowWorkItemLinkOK(s.T(), nil, nil, s.workItemLinkCtrl, *workItemLink.Data.ID)
	require.NotNil(s.T(), readIn)
	// Convert to model space and use equal function
	actual := link.WorkItemLink{}
	require.Nil(s.T(), link.ConvertLinkToModel(*readIn, &actual))
	require.True(s.T(), expected.Equal(actual))

	require.NotNil(s.T(), readIn.Data.Links, "The link MUST include a self link")
	require.NotEmpty(s.T(), readIn.Data.Links.Self, "The link MUST include a self link that's not empty")
}
예제 #2
0
// TestWorkItemLink_Equal Tests equality of two work item links
func TestWorkItemLink_Equal(t *testing.T) {
	t.Parallel()
	resource.Require(t, resource.UnitTest)

	a := link.WorkItemLink{
		ID:         satoriuuid.FromStringOrNil("0e671e36-871b-43a6-9166-0c4bd573e231"),
		SourceID:   1,
		TargetID:   2,
		LinkTypeID: satoriuuid.FromStringOrNil("966e982c-615c-4879-961f-56e912cbc4f2"),
	}

	// Test equality
	b := a
	require.True(t, a.Equal(b))

	// Test types
	c := convert.DummyEqualer{}
	require.False(t, a.Equal(c))

	// Test lifecycle
	b = a
	b.Lifecycle = gormsupport.Lifecycle{CreatedAt: time.Now().Add(time.Duration(1000))}
	require.False(t, a.Equal(b))

	// Test ID
	b = a
	b.ID = satoriuuid.FromStringOrNil("10616dae-0a28-4de5-9d79-c831dbcfd039")
	require.False(t, a.Equal(b))

	// Test Version
	b = a
	b.Version += 1
	require.False(t, a.Equal(b))

	// Test SourceID
	b = a
	b.SourceID = 1292387473
	require.False(t, a.Equal(b))

	// Test TargetID
	b = a
	b.TargetID = 93092303290
	require.False(t, a.Equal(b))

	// Test LinkTypeID
	b = a
	b.LinkTypeID = satoriuuid.FromStringOrNil("10a41146-3868-47cd-84ae-f96ea4c9d797")
	require.False(t, a.Equal(b))
}