@@ -24,6 +24,10 @@ func (s *Service) CreateTest(w http.ResponseWriter, r *http.Request) {
24
24
return
25
25
}
26
26
27
+ // Normalise test cases
28
+ test .VisibleTestCases = utils .NormaliseTestCaseFormat (test .VisibleTestCases )
29
+ test .HiddenTestCases = utils .NormaliseTestCaseFormat (test .HiddenTestCases )
30
+
27
31
// Automatically populate validation for input and output in test case
28
32
test .InputValidation = utils .GetDefaultValidation ()
29
33
test .OutputValidation = utils .GetDefaultValidation ()
@@ -54,6 +58,7 @@ func (s *Service) CreateTest(w http.ResponseWriter, r *http.Request) {
54
58
http .Error (w , "Test already exists for the question" , http .StatusConflict )
55
59
return
56
60
}
61
+ defer iter .Stop ()
57
62
58
63
// Save test to Firestore
59
64
docRef , _ , err := s .Client .Collection ("tests" ).Add (ctx , map [string ]interface {}{
@@ -103,3 +108,12 @@ func (s *Service) CreateTest(w http.ResponseWriter, r *http.Request) {
103
108
//"visibleTestCases": "2\nhello\nolleh\nHannah\nhannaH",
104
109
//"hiddenTestCases": "2\nHannah\nhannaH\nabcdefg\ngfedcba"
105
110
//}'
111
+
112
+ //curl -X POST http://localhost:8083/tests \
113
+ //-H "Content-Type: application/json" \
114
+ //-d "{
115
+ //\"questionDocRefId\": \"sampleDocRefId12345\",
116
+ //\"questionTitle\": \"Sample Question Title\",
117
+ //\"visibleTestCases\": \"2\\nhello\\nolleh\\nHannah\\nhannaH\",
118
+ //\"hiddenTestCases\": \"2\\nHannah\\nhannaH\\nabcdefg\\ngfedcba\"
119
+ //}"
0 commit comments