Skip to content

Commit 30a1918

Browse files
committed
add test for submitting assignments
1 parent a6ac2c8 commit 30a1918

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

api/api_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ func TestFetchASpecificProblem(t *testing.T) {
8686
assert.NoError(t, err)
8787
}
8888

89+
func TestSubmitAssignment(t *testing.T) {
90+
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
91+
w.WriteHeader(http.StatusCreated)
92+
93+
if err := respondWithFixture(w, "submit.json"); err != nil {
94+
t.Fatal(err)
95+
}
96+
}))
97+
defer ts.Close()
98+
99+
client := NewClient(&config.Config{API: ts.URL})
100+
iter := &Iteration{Key: "123", Code: "456", Path: "/foo/bar/bob/bob.rb", Dir: "/foo/bar"}
101+
sub, err := client.Submit(iter)
102+
assert.NoError(t, err)
103+
104+
assert.Equal(t, sub.Language, "ruby")
105+
}
106+
89107
func TestListTrack(t *testing.T) {
90108
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
91109
// check that we correctly built the URI path

fixtures/submit.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"error": null,
3+
"url": "a url",
4+
"track_id": "a track_id",
5+
"language": "ruby"
6+
}

0 commit comments

Comments
 (0)