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

v2: Testing Parsing #2930

Closed
sarge opened this issue Dec 14, 2019 · 4 comments
Closed

v2: Testing Parsing #2930

sarge opened this issue Dec 14, 2019 · 4 comments
Assignees
Milestone

Comments

@sarge
Copy link
Collaborator

sarge commented Dec 14, 2019

Wondering about the expectations that plugin writers should have around testing.

Currently looking at porting a cors library to v2. It has a bunch of nice tests to validate the caddyfile parsing.

I can appreciate keeping a bunch of implementation details hidden but access perhaps to this function would be a nice compromise?

func newTestDispenser(input string) *Dispenser {
	tokens, err := allTokens("Testfile", strings.NewReader(input))
	if err != nil && err != io.EOF {
		log.Fatalf("getting all tokens from input: %v", err)
	}
	return NewDispenser(tokens)
}
@mholt mholt added the v2 label Dec 17, 2019
@mholt mholt added this to the 2.0 milestone Dec 17, 2019
@mholt
Copy link
Member

mholt commented Dec 17, 2019

Good point, I need to spend some time and figure out what to expose for convenient testing in v2.

@mholt mholt self-assigned this Dec 17, 2019
@mholt mholt removed the v2 label Mar 23, 2020
@mholt mholt closed this as completed in 6fe04a3 Apr 1, 2020
@mholt
Copy link
Member

mholt commented Apr 1, 2020

@sarge I've exported NewTestDispenser in 6fe04a3.

@roblabla , as far as end-to-end integration testing, I believe @sarge can give you some pointers on that. 😃

@mholt mholt modified the milestones: 2.x, v2.0.0-rc.1 Apr 1, 2020
@JokerQyou
Copy link

Sorry to comment in a closed issue, but how are plug-in authors supposed to use this function? I don't think it can be referenced since it's defined in a test file.

@francislavoie
Copy link
Member

francislavoie commented May 23, 2020

@JokerQyou we have some discussion about that here: #3402, it's possible we'll move NewTestDispenser elsewhere.

Edit: I just opened a PR #3439 to do this.

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

No branches or pull requests

4 participants