@@ -94,27 +94,28 @@ func (suite *VotingTestSuite) TestCloseVoting() {
9494 s .votings = votingMock
9595 s .notes = notesMock
9696
97- req := technical_helper .NewTestRequestBuilder ("PUT" , "/" , nil )
97+ votingStatus := votings .Closed
98+ req := technical_helper .NewTestRequestBuilder ("PUT" , "/" , strings .NewReader (fmt .Sprintf (`{"status": "%s"}` , votingStatus )))
9899 req .Req = logger .InitTestLoggerRequest (req .Request ())
99100 req .AddToContext (identifiers .BoardIdentifier , boardId ).
100101 AddToContext (identifiers .VotingIdentifier , votingId )
101102 rr := httptest .NewRecorder ()
102103
103104 notesMock .EXPECT ().GetAll (mock .Anything , boardId ).Return ([]* notes.Note {}, nil )
104105
105- votingMock .EXPECT ().Close (mock .Anything , votingId , boardId , []votings.Note (nil )).
106+ votingMock .EXPECT ().Update (mock .Anything , votingId , boardId , []votings.Note (nil ), votings . Closed ).
106107 Return (& votings.Voting {Status : votings .Closed }, tt .err )
107108
108109 s .updateVoting (rr , req .Request ())
109110 suite .Equal (tt .expectedCode , rr .Result ().StatusCode )
110111 votingMock .AssertExpectations (suite .T ())
111- votingMock .AssertNumberOfCalls (suite .T (), "Close " , 1 )
112+ votingMock .AssertNumberOfCalls (suite .T (), "Update " , 1 )
112113 })
113114 }
114115
115116}
116117
117- func (suite * VotingTestSuite ) TestCancelVoting () {
118+ func (suite * VotingTestSuite ) TestAbortVoting () {
118119
119120 testParameterBundles := * TestParameterBundles {}.
120121 Append ("all ok" , http .StatusOK , nil , false , false , nil ).
@@ -123,7 +124,6 @@ func (suite *VotingTestSuite) TestCancelVoting() {
123124 for _ , tt := range testParameterBundles {
124125 suite .Run (tt .name , func () {
125126 s := new (Server )
126- //s.basePath = "/"
127127 votingMock := votings .NewMockVotingService (suite .T ())
128128 notesMock := notes .NewMockNotesService (suite .T ())
129129
@@ -132,21 +132,22 @@ func (suite *VotingTestSuite) TestCancelVoting() {
132132 s .votings = votingMock
133133 s .notes = notesMock
134134
135- req := technical_helper .NewTestRequestBuilder ("PUT" , "/" , strings .NewReader (`{"status": "ABORTED"}` ))
135+ votingStatus := votings .Aborted
136+ req := technical_helper .NewTestRequestBuilder ("PUT" , "/" , strings .NewReader (fmt .Sprintf (`{"status": "%s"}` , votingStatus )))
136137 req .Req = logger .InitTestLoggerRequest (req .Request ())
137138 req .AddToContext (identifiers .BoardIdentifier , boardId ).
138139 AddToContext (identifiers .VotingIdentifier , votingId )
139140
140141 notesMock .EXPECT ().GetAll (mock .Anything , boardId ).Return ([]* notes.Note {}, nil )
141142
142- votingMock .EXPECT ().Cancel (mock .Anything , votingId , boardId , []votings.Note (nil )).
143- Return (& votings.Voting {Status : votings .Canceled }, tt .err )
143+ votingMock .EXPECT ().Update (mock .Anything , votingId , boardId , []votings.Note (nil ), votings . Aborted ).
144+ Return (& votings.Voting {Status : votings .Aborted }, tt .err )
144145
145146 rr := httptest .NewRecorder ()
146147 s .updateVoting (rr , req .Request ())
147148 suite .Equal (tt .expectedCode , rr .Result ().StatusCode )
148149 votingMock .AssertExpectations (suite .T ())
149- votingMock .AssertNumberOfCalls (suite .T (), "Cancel " , 1 )
150+ votingMock .AssertNumberOfCalls (suite .T (), "Update " , 1 )
150151 })
151152 }
152153}
0 commit comments