Exemplo n.º 1
0
func TestPutSubmission(t *testing.T) {
	parser.LoadPlugins("plugin")
	router, oldMongo := preTest()
	defer func(s DataStorage) { mongo = s }(oldMongo)

	params := map[string]string{
		"submission-meta": "{ \"owner\": \"radek\",   \"assignmentId\": \"55c7a86e8543eb08edca6b51\",   \"id\":\"25\" }",
	}
	w := httptest.NewRecorder()
	r, _ := newfileUploadRequest("/test", params, "submission-data", "test/test.zip")

	router.POST("/test", putSubmission)
	router.ServeHTTP(w, r)
	if w.Code != 200 {
		t.Errorf("Bad response %v", w)
	}
	time.Sleep(100 * time.Millisecond) //TODO solve DATA RACE in test
}
Exemplo n.º 2
0
func TestPutSubmissionInvalidAssignment(t *testing.T) {
	parser.LoadPlugins("plugin")
	router, oldMongo := preTest()
	defer func(s DataStorage) { mongo = s }(oldMongo)

	params := map[string]string{
		"submission-meta": "{ \"owner\": \"'$p'\",   \"assignmentId\": \"\",   \"id\":\"'$p'\" }",
	}
	w := httptest.NewRecorder()
	r, _ := newfileUploadRequest("/test", params, "submission-data", "test/test.zip")

	router.POST("/test", putSubmission)
	router.ServeHTTP(w, r)
	if w.Code != 405 {
		t.Errorf("Bad response expected %s got %v", 405, w)
	}

	time.Sleep(100 * time.Millisecond)
}
Exemplo n.º 3
0
//Load plugins
func loadPlugins() {
	//Load plugins
	parser.SetLogger(Log)
	parser.LoadPlugins("plugin")
}