(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func 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 |
| 145 | func TestGetDefaultStdStatusMappingEmptyStatusList(t *testing.T) { |
nothing calls this directly
no test coverage detected