MCPcopy Index your code
hub / github.com/apache/devlake / TestGetTapdTypeMappings

Function TestGetTapdTypeMappings

backend/plugins/tapd/tasks/shared_test.go:98–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

96}
97
98func TestGetTapdTypeMappings(t *testing.T) {
99 // create a mock database connection
100 db := new(mockdal.Dal)
101 // create some test data
102 data := &TapdTaskData{
103 Options: &TapdOptions{
104 ConnectionId: 1,
105 WorkspaceId: 2,
106 },
107 }
108
109 issueTypes := make([]models.TapdWorkitemType, 0)
110 issueTypes = append(issueTypes, models.TapdWorkitemType{
111 ConnectionId: 1,
112 WorkspaceId: 2,
113 Id: 1,
114 Name: "Story",
115 })
116 issueTypes = append(issueTypes, models.TapdWorkitemType{
117 ConnectionId: 1,
118 WorkspaceId: 2,
119 Id: 2,
120 Name: "Bug",
121 })
122 db.On("All", mock.Anything, mock.Anything).Run(func(args mock.Arguments) {
123 dst := args.Get(0).(*[]models.TapdWorkitemType)
124 *dst = issueTypes
125 }).Return(nil).Once()
126 // call the function being tested
127 result, err := getTapdTypeMappings(data, db, "story")
128
129 // check if the result is correct
130 if err != nil {
131 t.Errorf("getTapdTypeMappings returned an error: %v", err)
132 }
133 if len(result) != 2 {
134 t.Errorf("getTapdTypeMappings returned %d items, expected 2", len(result))
135 }
136 if result[1] != "Story" {
137 t.Errorf("getTapdTypeMappings returned incorrect value for ID 1: %s", result[1])
138 }
139 if result[2] != "Bug" {
140 t.Errorf("getTapdTypeMappings returned incorrect value for ID 2: %s", result[2])
141 }
142}
143
144// test case for when the status list is empty
145func TestGetDefaultStdStatusMappingEmptyStatusList(t *testing.T) {

Callers

nothing calls this directly

Calls 3

getTapdTypeMappingsFunction · 0.85
RunMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected