Skip to content

Improve the assertions for the downloaded solution metadata#676

Merged
kytrinyx merged 2 commits intomasterfrom
better-metadata
Jul 25, 2018
Merged

Improve the assertions for the downloaded solution metadata#676
kytrinyx merged 2 commits intomasterfrom
better-metadata

Conversation

@kytrinyx
Copy link
Copy Markdown
Member

The hard-coded JSON for the metadata was annoying me. The big JSON is hard to read. We improved it a bit by writing the JSON as multiline, and then compacting it using json.Compact() but it still felt brittle.

This improves it further by reading the JSON into a solution struct and just checking the fields we care about.

Copy link
Copy Markdown
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach better for sure. I thought about recommending that you drop the requestorSelf and requestorOther before but I never mentioned it.

This looks good. I have two minor recommended changes before you merge.

Comment thread cmd/download_test.go Outdated
assert.NoError(t, err)

ts := fakeDownloadServer(tc.requestor)
ts := fakeDownloadServer(fmt.Sprintf("%v", tc.requester))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strconv.FormatBool(tc.requester) is what you want here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh, love it. Thanks!

Comment thread cmd/download_test.go
flags: map[string]string{"uuid": "bogus-id"},
},
{
requestor: requestorOther,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These constants are still defined below but no longer used

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you for catching that.

We don't need to check the entire downloaded JSON, we just want to make sure it got
downloaded and has the crucial bits of data that we passed to the server.
@kytrinyx
Copy link
Copy Markdown
Member Author

I fixed the last details and force pushed, @nywilken.

@kytrinyx kytrinyx merged commit ea7d503 into master Jul 25, 2018
@kytrinyx kytrinyx deleted the better-metadata branch July 25, 2018 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants