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

Retry Post on getsockopt: connection refused #17

Closed
nickwales opened this issue Dec 1, 2016 · 1 comment
Closed

Retry Post on getsockopt: connection refused #17

nickwales opened this issue Dec 1, 2016 · 1 comment

Comments

@nickwales
Copy link

The sample POST test exits immediately when there is no server on the other end. (e.g. changing 9000 to 9001)

Any suggestions on how to handle retrying this?

@sethgrid
Copy link
Owner

sethgrid commented Dec 2, 2016

Hi @nickwales ,
I added a new case the the sample code that shows that max retries is honored for posting when there is no server on the other end. Let me know if things are still unclear. I'll close out this issue in a few days if I don't hear back. Cheers!

	log.Println("> pester.Post with retries to non-existant url")
	{
		client := pester.New()
		client.MaxRetries = 3
		client.KeepLog = true

		_, err := client.Post("http://localhost:9001", "application/json", strings.NewReader(`{"json":true}`))
		if err == nil {
			log.Printf("expected to error after max retries of 3")
		}

		if len(client.ErrLog) != 3 {
			log.Fatalf("expected 3 error logs, got %d: %v", len(client.ErrLog), client.ErrLog)
		}
		log.Printf("POST: %v\n\n", err)
	}

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

2 participants