@@ -655,13 +655,17 @@ func TestPostQuestionnaire(t *testing.T) {
655655 isErr bool
656656 err error
657657 normalizedDueDate bool
658+ hasReminder * bool
658659 }
659660 type test struct {
660661 description string
661662 args
662663 expect
663664 }
664665
666+ hasReminderTrue := true
667+ hasReminderFalse := false
668+
665669 responseDueDateTimeMinus := time .Now ().Add (- 24 * time .Hour )
666670 responseDueDateTimeNearlyNowPast := time .Now ().Add (- 3 * time .Second )
667671 responseDueDateTimePlus := time .Now ().Add (24 * time .Hour )
@@ -723,6 +727,9 @@ func TestPostQuestionnaire(t *testing.T) {
723727 Title : "第1回集会らん☆ぷろ募集アンケート" ,
724728 },
725729 },
730+ expect : expect {
731+ hasReminder : & hasReminderTrue ,
732+ },
726733 },
727734 {
728735 description : "invalid response due date time" ,
@@ -1003,6 +1010,33 @@ func TestPostQuestionnaire(t *testing.T) {
10031010 },
10041011 },
10051012 },
1013+ {
1014+ description : "not published with response due date time" ,
1015+ args : args {
1016+ params : openapi.PostQuestionnaireJSONRequestBody {
1017+ Admin : sampleAdmin ,
1018+ Description : "第1回集会らん☆ぷろ参加者募集" ,
1019+ IsDuplicateAnswerAllowed : true ,
1020+ IsAnonymous : false ,
1021+ IsPublished : false ,
1022+ Questions : []openapi.NewQuestion {
1023+ sampleQuestionSettingsText ,
1024+ sampleQuestionSettingsTextLong ,
1025+ sampleQuestionSettingsNumber ,
1026+ sampleQuestionSettingsSingleChoice ,
1027+ sampleQuestionSettingsMultipleChoice ,
1028+ sampleQeustionsettingsScale ,
1029+ },
1030+ ResponseDueDateTime : & responseDueDateTimePlus ,
1031+ ResponseViewableBy : "anyone" ,
1032+ Target : sampleTarget ,
1033+ Title : "第1回集会らん☆ぷろ募集アンケート" ,
1034+ },
1035+ },
1036+ expect : expect {
1037+ hasReminder : & hasReminderFalse ,
1038+ },
1039+ },
10061040 {
10071041 description : "invalid question settings number" ,
10081042 args : args {
@@ -1153,6 +1187,12 @@ func TestPostQuestionnaire(t *testing.T) {
11531187 assertion .Equal (testCase .args .params .Target .Groups , questionnaireDetail .Target .Groups , "target groups not equal" )
11541188
11551189 assertion .Equal (testCase .args .params .Title , questionnaireDetail .Title , "title not equal" )
1190+
1191+ if testCase .expect .hasReminder != nil {
1192+ remindStatus , err := re .CheckRemindStatus (questionnaireDetail .QuestionnaireId )
1193+ assertion .NoError (err , testCase .description , "no error checking remind status" )
1194+ assertion .Equal (* testCase .expect .hasReminder , remindStatus , testCase .description , "reminder status" )
1195+ }
11561196 }
11571197}
11581198
@@ -1260,15 +1300,19 @@ func TestEditQuestionnaire(t *testing.T) {
12601300 isNewQuestion []bool
12611301 }
12621302 type expect struct {
1263- isErr bool
1264- err error
1303+ isErr bool
1304+ err error
1305+ hasReminder * bool
12651306 }
12661307 type test struct {
12671308 description string
12681309 args
12691310 expect
12701311 }
12711312
1313+ hasReminderTrue := true
1314+ hasReminderFalse := false
1315+
12721316 responseDueDateTimeMinus := time .Now ().Add (- 24 * time .Hour )
12731317 responseDueDateTimePlus := time .Now ().Add (24 * time .Hour )
12741318
@@ -1362,6 +1406,9 @@ func TestEditQuestionnaire(t *testing.T) {
13621406 },
13631407 isNewQuestion : []bool {false , false , false , false , false , false },
13641408 },
1409+ expect : expect {
1410+ hasReminder : & hasReminderTrue ,
1411+ },
13651412 },
13661413 {
13671414 description : "invalid question id" ,
@@ -1647,6 +1694,34 @@ func TestEditQuestionnaire(t *testing.T) {
16471694 isNewQuestion : []bool {false , false , false , false , false , false },
16481695 },
16491696 },
1697+ {
1698+ description : "not published with response due date time" ,
1699+ args : args {
1700+ params : openapi.PostQuestionnaireJSONRequestBody {
1701+ Admin : sampleAdmin ,
1702+ Description : "第1回集会らん☆ぷろ参加者募集" ,
1703+ IsDuplicateAnswerAllowed : true ,
1704+ IsAnonymous : false ,
1705+ IsPublished : false ,
1706+ Questions : []openapi.NewQuestion {
1707+ sampleQuestionSettingsText ,
1708+ sampleQuestionSettingsTextLong ,
1709+ sampleQuestionSettingsNumber ,
1710+ sampleQuestionSettingsSingleChoice ,
1711+ sampleQuestionSettingsMultipleChoice ,
1712+ sampleQeustionsettingsScale ,
1713+ },
1714+ ResponseDueDateTime : & responseDueDateTimePlus ,
1715+ ResponseViewableBy : "anyone" ,
1716+ Target : sampleTarget ,
1717+ Title : "第1回集会らん☆ぷろ募集アンケート" ,
1718+ },
1719+ isNewQuestion : []bool {false , false , false , false , false , false },
1720+ },
1721+ expect : expect {
1722+ hasReminder : & hasReminderFalse ,
1723+ },
1724+ },
16501725 {
16511726 description : "invalid question settings number" ,
16521727 args : args {
@@ -1855,6 +1930,12 @@ func TestEditQuestionnaire(t *testing.T) {
18551930 questionnaireDetailExpected .Questions [i ].CreatedAt = questionnaireDetailEdited .Questions [i ].CreatedAt
18561931 }
18571932 assertion .Equal (questionnaireDetailExpected , questionnaireDetailEdited , testCase .description , "questionnaireDetail" )
1933+
1934+ if testCase .expect .hasReminder != nil {
1935+ remindStatus , err := re .CheckRemindStatus (questionnaireDetail .QuestionnaireId )
1936+ assertion .NoError (err , testCase .description , "no error checking remind status" )
1937+ assertion .Equal (* testCase .expect .hasReminder , remindStatus , testCase .description , "reminder status" )
1938+ }
18581939 }
18591940}
18601941
0 commit comments