@@ -2,8 +2,6 @@ package reactions
2
2
3
3
import (
4
4
"context"
5
- "database/sql"
6
- "errors"
7
5
"log"
8
6
"testing"
9
7
@@ -62,31 +60,13 @@ func (suite *DatabaseReactionTestSuite) Test_Database_CreateReaction() {
62
60
assert .Equal (t , reaction .ReactionType , dbReaction .ReactionType )
63
61
}
64
62
65
- func (suite * DatabaseReactionTestSuite ) Test_Database_CreateReaction_MultipleReaction () {
66
- t := suite .T ()
67
- database := NewReactionsDatabase (suite .db )
68
-
69
- reactionInsert := DatabaseReactionInsert {
70
- Note : suite .notes ["Update" ].id ,
71
- User : suite .users ["Santa" ].id ,
72
- ReactionType : Like ,
73
- }
74
-
75
- dbReaction , err := database .Create (context .Background (), suite .boards ["Write" ].id , reactionInsert )
76
-
77
- assert .Equal (t , DatabaseReaction {}, dbReaction )
78
- assert .Equal (t , errors .New ("cannot make multiple reactions on the same note by the same user" ), err )
79
- }
80
-
81
63
func (suite * DatabaseReactionTestSuite ) Test_Database_Delete () {
82
64
t := suite .T ()
83
65
database := NewReactionsDatabase (suite .db )
84
66
85
- boardId := suite .boards ["Write" ].id
86
- userId := suite .users ["Stan" ].id
87
67
reactionId := suite .reactions ["Delete" ].ID
88
68
89
- err := database .Delete (context .Background (), boardId , userId , reactionId )
69
+ err := database .Delete (context .Background (), reactionId )
90
70
91
71
assert .Nil (t , err )
92
72
}
@@ -95,35 +75,17 @@ func (suite *DatabaseReactionTestSuite) Test_Database_Delete_NotFound() {
95
75
t := suite .T ()
96
76
database := NewReactionsDatabase (suite .db )
97
77
98
- boardId := suite .boards ["Write" ].id
99
- userId := suite .users ["Stan" ].id
100
78
reactionId := uuid .New ()
101
79
102
- err := database .Delete (context .Background (), boardId , userId , reactionId )
103
-
104
- assert .NotNil (t , err )
105
- assert .Equal (t , sql .ErrNoRows , err )
106
- }
107
-
108
- func (suite * DatabaseReactionTestSuite ) Test_Database_Delete_UserError () {
109
- t := suite .T ()
110
- database := NewReactionsDatabase (suite .db )
111
-
112
- boardId := suite .boards ["Write" ].id
113
- userId := suite .users ["Stan" ].id
114
- reactionId := suite .reactions ["Update" ].ID
115
-
116
- err := database .Delete (context .Background (), boardId , userId , reactionId )
80
+ err := database .Delete (context .Background (), reactionId )
117
81
118
- assert .NotNil (t , err )
119
- assert .Equal (t , common .ForbiddenError (errors .New ("forbidden" )), err )
82
+ assert .Nil (t , err )
120
83
}
121
84
122
85
func (suite * DatabaseReactionTestSuite ) Test_Database_Update () {
123
86
t := suite .T ()
124
87
database := NewReactionsDatabase (suite .db )
125
88
126
- boardId := suite .boards ["Write" ].id
127
89
userId := suite .users ["Santa" ].id
128
90
noteId := suite .notes ["Update" ].id
129
91
reactionId := suite .reactions ["Update" ].ID
@@ -135,7 +97,7 @@ func (suite *DatabaseReactionTestSuite) Test_Database_Update() {
135
97
ReactionType : Poop ,
136
98
}
137
99
138
- dbReaction , err := database .Update (context .Background (), boardId , userId , reactionId , DatabaseReactionUpdate {ReactionType : Poop })
100
+ dbReaction , err := database .Update (context .Background (), reactionId , DatabaseReactionUpdate {ReactionType : Poop })
139
101
140
102
assert .Nil (t , err )
141
103
assert .Equal (t , reaction .ID , dbReaction .ID )
@@ -148,30 +110,12 @@ func (suite *DatabaseReactionTestSuite) Test_Database_Update_NotFound() {
148
110
t := suite .T ()
149
111
database := NewReactionsDatabase (suite .db )
150
112
151
- boardId := suite .boards ["Write" ].id
152
- userId := suite .users ["Santa" ].id
153
113
reactionId := uuid .New ()
154
114
155
- dbReaction , err := database .Update (context .Background (), boardId , userId , reactionId , DatabaseReactionUpdate {ReactionType : Poop })
115
+ dbReaction , err := database .Update (context .Background (), reactionId , DatabaseReactionUpdate {ReactionType : Poop })
156
116
157
117
assert .Equal (t , DatabaseReaction {}, dbReaction )
158
- assert .NotNil (t , err )
159
- assert .Equal (t , sql .ErrNoRows , err )
160
- }
161
-
162
- func (suite * DatabaseReactionTestSuite ) Test_Database_Update_UserError () {
163
- t := suite .T ()
164
- database := NewReactionsDatabase (suite .db )
165
-
166
- boardId := suite .boards ["Write" ].id
167
- userId := suite .users ["Stan" ].id
168
- reactionId := suite .reactions ["Update" ].ID
169
-
170
- dbReaction , err := database .Update (context .Background (), boardId , userId , reactionId , DatabaseReactionUpdate {ReactionType : Poop })
171
-
172
- assert .Equal (t , DatabaseReaction {}, dbReaction )
173
- assert .NotNil (t , err )
174
- assert .Equal (t , common .ForbiddenError (errors .New ("forbidden" )), err )
118
+ assert .Nil (t , err )
175
119
}
176
120
177
121
func (suite * DatabaseReactionTestSuite ) Test_Database_GetReaction () {
0 commit comments