-
-
Notifications
You must be signed in to change notification settings - Fork 368
Add --team flag to download command #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,14 +107,19 @@ func TestDownload(t *testing.T) { | |
| expectedDir: filepath.Join("users", "alice"), | ||
| flags: map[string]string{"uuid": "bogus-id"}, | ||
| }, | ||
| { | ||
| requester: true, | ||
| expectedDir: filepath.Join("teams", "bogus-team"), | ||
| flags: map[string]string{"exercise": "bogus-exercise", "track": "bogus-track", "team": "bogus-team"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| tmpDir, err := ioutil.TempDir("", "download-cmd") | ||
| defer os.RemoveAll(tmpDir) | ||
| assert.NoError(t, err) | ||
|
|
||
| ts := fakeDownloadServer(strconv.FormatBool(tc.requester)) | ||
| ts := fakeDownloadServer(strconv.FormatBool(tc.requester), tc.flags["team"]) | ||
| defer ts.Close() | ||
|
|
||
| v := viper.New() | ||
|
|
@@ -149,7 +154,7 @@ func TestDownload(t *testing.T) { | |
| } | ||
| } | ||
|
|
||
| func fakeDownloadServer(requestor string) *httptest.Server { | ||
| func fakeDownloadServer(requestor, teamSlug string) *httptest.Server { | ||
| mux := http.NewServeMux() | ||
| server := httptest.NewServer(mux) | ||
|
|
||
|
|
@@ -165,11 +170,16 @@ func fakeDownloadServer(requestor string) *httptest.Server { | |
| fmt.Fprint(w, "") | ||
| }) | ||
|
|
||
| payloadBody := fmt.Sprintf(payloadTemplate, requestor, server.URL+"/") | ||
| mux.HandleFunc("/solutions/latest", func(w http.ResponseWriter, r *http.Request) { | ||
| team := "null" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment about the Team field for the Solution type. |
||
| if teamSlug := r.FormValue("team_id"); teamSlug != "" { | ||
| team = fmt.Sprintf(`{"name": "Bogus Team", "slug": "%s"}`, teamSlug) | ||
| } | ||
| payloadBody := fmt.Sprintf(payloadTemplate, requestor, team, server.URL+"/") | ||
| fmt.Fprint(w, payloadBody) | ||
| }) | ||
| mux.HandleFunc("/solutions/bogus-id", func(w http.ResponseWriter, r *http.Request) { | ||
| payloadBody := fmt.Sprintf(payloadTemplate, requestor, "null", server.URL+"/") | ||
| fmt.Fprint(w, payloadBody) | ||
| }) | ||
|
|
||
|
|
@@ -215,6 +225,7 @@ const payloadTemplate = ` | |
| "handle": "alice", | ||
| "is_requester": %s | ||
| }, | ||
| "team": %s, | ||
| "exercise": { | ||
| "id": "bogus-exercise", | ||
| "instructions_url": "http://example.com/bogus-exercise", | ||
|
|
@@ -226,9 +237,9 @@ const payloadTemplate = ` | |
| }, | ||
| "file_download_base_url": "%s", | ||
| "files": [ | ||
| "/file-1.txt", | ||
| "/subdir/file-2.txt", | ||
| "/file-3.txt" | ||
| "/file-1.txt", | ||
| "/subdir/file-2.txt", | ||
| "/file-3.txt" | ||
| ], | ||
| "iteration": { | ||
| "submitted_at": "2017-08-21t10:11:12.130z" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ type Solution struct { | |
| Track string `json:"track"` | ||
| Exercise string `json:"exercise"` | ||
| ID string `json:"id"` | ||
| Team string `json:"team,omitempty"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is the intended empty state for Team “”, null? I ask because I am wondering if this should be of type *string. If the empty state is “” then your example of “null” in the test should be changed.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The empty state of the solution metadata is |
||
| URL string `json:"url"` | ||
| Handle string `json:"handle"` | ||
| IsRequester bool `json:"is_requester"` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit confusing. In payload it is a struct here Team is a string. I understand the difference but maybe it should be TeamSlug. Or maybe have a different name in the Solution struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think
TeamSlugmakes sense.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it back, actually.
In the solution we're storing just the minimal metadata. The payload has more data about both the track and the team, which we can use to communicate about it if we want to.
I would rather change the solution type later to have a more fleshed out team than to call this
TeamSlugnow.