Skip to content
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

chartsvc: Unit and integration tests #329

Merged
merged 7 commits into from
May 31, 2018

Conversation

sameersbn
Copy link
Contributor

Closes #301

@sameersbn sameersbn requested a review from prydonius May 25, 2018 12:26
Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

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

thanks @sameersbn, lgtm in general. A few suggestions for some more tests we could add.

@@ -95,39 +95,39 @@ func listRepoCharts(w http.ResponseWriter, req *http.Request, params Params) {
func getChart(w http.ResponseWriter, req *http.Request, params Params) {
db, closer := dbSession.DB()
defer closer()
var chart *models.Chart
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reasoning behind these pointer to value changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was having trouble getting the mock interface match the expectation description. Simplest was to fix this was to remove the double reference.

mock: Unexpected Method Call
-----------------------------

One(**models.Chart)
		0: (**models.Chart)(0xc4200b41a8)

The closest call I have is: 

One(*models.Chart)
		0: &models.Chart{ID:"", Name:"", Repo:models.Repo{Name:"", URL:""}, Description:"", Home:"", Keywords:[]string(nil), Maintainers:[]models.Maintainer(nil), Sources:[]string(nil), Icon:"", RawIcon:[]uint8(nil), ChartVersions:[]models.ChartVersion(nil)}

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm okay, I think the tests in monocular had a similar thing though, but it's not a big problem either way.

assert.Equal(t, cResponse.Type, "chart", "response type is chart")
assert.Equal(t, cResponse.ID, tt.chart.ID, "chart ID should be the same")
assert.Equal(t, cResponse.Attributes.(models.Chart).ChartVersions, tt.chart.ChartVersions, "chart version in the response should be the same")
})
Copy link
Contributor

Choose a reason for hiding this comment

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

can we check that the latestChartVersion relationship points to tt.chart.ChartVersions[0]?

Copy link
Contributor

Choose a reason for hiding this comment

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

also the selfLink

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

cvResponse := newChartVersionResponse(&tt.chart, tt.chart.ChartVersions[i])
assert.Equal(t, cvResponse.Type, "chartVersion", "response type is chartVersion")
assert.Equal(t, cvResponse.ID, tt.chart.ID+"-"+tt.chart.ChartVersions[i].Version, "reponse id should have chart version suffix")
assert.Equal(t, cvResponse.Attributes.(models.ChartVersion).Version, tt.chart.ChartVersions[i].Version, "chart version in the response should be the same")
Copy link
Contributor

Choose a reason for hiding this comment

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

check the selfLink and "chart" relationship here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

name string
chart models.Chart
}{
{"my-chart", models.Chart{
Copy link
Contributor

Choose a reason for hiding this comment

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

add a test for no chart versions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

@sameersbn
Copy link
Contributor Author

updated the PR. Please review.

@prydonius
Copy link
Contributor

thanks for the separate commits, was a lot easier to review! lgtm!

@prydonius prydonius merged commit be14404 into vmware-tanzu:master May 31, 2018
@sameersbn sameersbn deleted the chartsvc-tests branch June 1, 2018 08:58
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