forked from edulinq/autograder-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
110 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ func main() { | |
// Split the parameter into it's key and value. | ||
parts := strings.SplitN(arg, ":", 2) | ||
if len(parts) != 2 { | ||
log.Fatal("Invalid parameter format: missing a colon. Expected format is 'key:value', e.g., 'target-email:[email protected]'.", log.NewAttr("parameter", parts)) | ||
log.Fatal("Invalid parameter format: missing a colon. Expected format is 'key:value', e.g., 'id:123'.", log.NewAttr("parameter", parts)) | ||
|
||
// Return to prevent further execution after log.Fatal(). | ||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,13 @@ func TestCallApiEndpointBase(test *testing.T) { | |
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedStderrSubstring: `Failed to find the endpoint. | {"endpoint":"ZZZ"}`, | ||
ExpectedExitCode: 1, | ||
ExpectEmptyStdout: true, | ||
}, | ||
endpoint: "ZZZ", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
"target-submission:1697406256", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedStderrSubstring: `Invalid parameter format: missing a colon. Expected format is 'key:value', e.g., 'target-email:[email protected]'. | {"parameter":["course-idcourse101"]}`, | ||
ExpectedStderrSubstring: `Invalid parameter format: missing a colon. Expected format is 'key:value', e.g., 'id:123'. | {"parameter":["course-idcourse101"]}`, | ||
ExpectedExitCode: 1, | ||
ExpectEmptyStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/user/peek", | ||
parameters: []string{ | ||
|
@@ -50,39 +42,101 @@ func TestCallApiEndpointBase(test *testing.T) { | |
|
||
// Base functionality for each supported endpoint. | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/get", | ||
parameters: []string{ | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/list", | ||
parameters: []string{ | ||
"course-id:course101", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/users/drop", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/users/get", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/users/list", | ||
parameters: []string{ | ||
"course-id:course101", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/course/attempts", | ||
parameters: []string{ | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/course/scores", | ||
parameters: []string{ | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/user/attempt", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
"target-submission:1697406256", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/user/history", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
"target-submission:1697406256", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/fetch/user/peek", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
|
@@ -92,15 +146,58 @@ func TestCallApiEndpointBase(test *testing.T) { | |
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "courses/assignments/submissions/remove", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
"assignment-id:hw0", | ||
"target-submission:1697406256", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "lms/user/get", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
"course-id:course101", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "logs/query", | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "metadata/describe", | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "users/get", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
}, | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "users/list", | ||
}, | ||
{ | ||
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
IgnoreStdout: true, | ||
}, | ||
endpoint: "users/remove", | ||
parameters: []string{ | ||
"target-email:[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,6 @@ func TestCourseUserDropBase(test *testing.T) { | |
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedExitCode: 1, | ||
ExpectedStderrSubstring: `Could not find course: 'ZZZ'.`, | ||
ExpectEmptyStdout: true, | ||
}, | ||
targetEmail: "[email protected]", | ||
courseID: "ZZZ", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ func TestCourseUserGetBase(test *testing.T) { | |
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedExitCode: 1, | ||
ExpectedStderrSubstring: `Could not find course: 'ZZZ'."`, | ||
ExpectEmptyStdout: true, | ||
}, | ||
targetEmail: "[email protected]", | ||
courseID: "ZZZ", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ func TestPeekBase(test *testing.T) { | |
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedExitCode: 1, | ||
ExpectedStderrSubstring: `Could not find course: 'ZZZ'.`, | ||
ExpectEmptyStdout: true, | ||
}, | ||
targetEmail: "[email protected]", | ||
courseID: "ZZZ", | ||
|
@@ -77,7 +76,6 @@ func TestPeekBase(test *testing.T) { | |
CommonCMDTestCase: cmd.CommonCMDTestCase{ | ||
ExpectedExitCode: 1, | ||
ExpectedStderrSubstring: `Could not find assignment: 'zzz'.`, | ||
ExpectEmptyStdout: true, | ||
}, | ||
targetEmail: "[email protected]", | ||
courseID: "course101", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters