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
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. pkgsite Suggested Issues that may be good for new contributors looking for work to do.

Comments

@julieqiu
Copy link
Member

julieqiu commented Jul 7, 2020

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

@julieqiu julieqiu added Suggested Issues that may be good for new contributors looking for work to do. help wanted NeedsFix The path to resolution is known, but the work has not been done. pkgsite labels Jul 7, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jul 7, 2020
@vikramcse
Copy link

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

@julieqiu
Copy link
Member Author

julieqiu commented Jul 9, 2020

Please do!

@vikramcse
Copy link

@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?

@kirandasika0
Copy link

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

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Dec 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. pkgsite Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

4 participants