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

Tests #190

Merged
merged 24 commits into from
Feb 3, 2020
Merged

Tests #190

merged 24 commits into from
Feb 3, 2020

Conversation

stmcallister
Copy link
Contributor

@stmcallister stmcallister commented Jan 9, 2020

This PR adds tests for each of the endpoints, with the exception of events_v2.

@theckman
Copy link
Collaborator

theckman commented Jan 9, 2020

Can you please break this in to smaller PRs so reviewing it is feasible?

Copy link
Collaborator

@theckman theckman left a comment

Choose a reason for hiding this comment

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

I'd like to review this and at such a large size that is hard to do. I would also like to avoid the additional dependency.

go.mod Outdated
@@ -7,5 +7,6 @@ require (
github.com/mitchellh/cli v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.2.2
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to see us stick to the standard library as much as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@theckman , something more like this? Where I use reflect for the comparison in an if statement.

func TestAbility_ListAbilities(t *testing.T) {
	t.Parallel()
	setup()
	defer teardown()

	mux.HandleFunc("/abilities", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, "GET")
		w.Write([]byte(`{"abilities": ["sso"]}`))
	})

	var client = &Client{apiEndpoint: server.URL, authToken: "foo", HTTPClient: defaultHTTPClient}
	want := &ListAbilityResponse{Abilities: []string{"sso"}}

	res, err := client.ListAbilities()

	if err != nil {
		t.Fatal(err)
	}

	if !reflect.DeepEqual(res, want) {
		t.Errorf("returned %#v; want %#v", res, want)
	}
}

Also, as for the size of the PR, adding testing is no small task. But didn't seem I should do in pieces. In hindsight, might have been smarter to propose a testing style and then go forward.

@stmcallister stmcallister requested a review from theckman January 11, 2020 00:40
@stmcallister
Copy link
Contributor Author

Hey @theckman. I went ahead and removed the testify dependency from the project. Also, as mentioned before, I wanted to introduce testing by covering as many of the functions as possible, rather than introduce testing incrementally. The project needs testing, and I think this will help review and merge other PRs faster and with more confidence. Thoughts?

@stmcallister
Copy link
Contributor Author

Hey @theckman, do you have an idea of when you will you be able to review this? If you don't have the bandwidth, maybe we could tag another reviewer?

@stmcallister stmcallister dismissed theckman’s stale review February 3, 2020 20:35

Made the changes requested. Messaged reviewer, and provided time to respond. Please post comments or issues if you see anything amiss with the changes.

@stmcallister stmcallister merged commit 65bf90f into master Feb 3, 2020
@theckman
Copy link
Collaborator

theckman commented Feb 3, 2020

@stmcallister sorry for the delay; was gone all of last week for yearly planning. Totally nuked me for the weekend. I'll do a review of this, and direct comments to you to be addressed later.

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.

3 participants