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

x/pkgsite: add tests for frontend.LatestVersion #40107

Closed
julieqiu opened this issue Jul 7, 2020 · 5 comments
Closed

x/pkgsite: add tests for frontend.LatestVersion #40107

julieqiu opened this issue Jul 7, 2020 · 5 comments

Comments

@julieqiu
Copy link
Contributor

@julieqiu julieqiu commented Jul 7, 2020

Add tests for frontend.latestMinorVersion, which is used to return the latest version of a path.

@vikramcse
Copy link

@vikramcse vikramcse commented Jul 9, 2020

@julieqiu I would like to work on this issue. can I pick this?

@julieqiu
Copy link
Contributor Author

@julieqiu julieqiu commented Jul 9, 2020

Please do!

@vikramcse
Copy link

@vikramcse vikramcse commented Jul 11, 2020

@julieqiu I have gone through TestServer test from server_test.go file. I am thinking to write the test cases for latestVersion in similar way.

1. testCases := []serverTestCase{
		{
			name:           "module packages tab latest version",
			urlPath:        fmt.Sprintf("/mod/%s?tab=packages", sample.ModulePath),
			wantStatusCode: http.StatusOK,
			// Fall back to the latest version.
			want: in("",
				in("div.DetailsHeader-version", text("v1.0.0"))),
		},
	}
  1. insertTestModules()
  2. create a server i.e s = NewServer()
  3. create a middeware middleware.LatestVersion(s.LatestVersion) as s.LatestVersion is intended to be a parameter of middleware.LatestVersion
  4. call latestVersion method i.e s.latestVersion(context.Background(), packagePath, modulePath, pageType)
6. for _, tc := range testCases {
		a. create a httptest.NewRecorder()
		b. create a new httptest request to the urlPath
		c. parse the res.Body
		d. here in res.Body we can check compare the `requested` and `want` version
	}

Before moving forward with this solution, can you please let me know that is this the right approach?

@gopherbot gopherbot added the go.dev label Sep 18, 2020
@julieqiu julieqiu removed the go.dev label Sep 19, 2020
@gopherbot gopherbot added the go.dev label Sep 19, 2020
@julieqiu julieqiu removed the go.dev label Sep 22, 2020
@kirandasika98
Copy link

@kirandasika98 kirandasika98 commented Dec 15, 2020

Hi @julieqiu, Can I pickup this issue? If, @vikramcse is okay with it?

@gopherbot
Copy link

@gopherbot gopherbot commented Dec 16, 2020

Change https://golang.org/cl/278752 mentions this issue: internal/frontend: added tests for frontend.LatestVersion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants