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

API refactor: add attested nodes query tests #1690

Merged

Conversation

MarcosDY
Copy link
Collaborator

Add unit tests to validate attested nodes query

Signed-off-by: Marcos Yacob <marcos@scytale.io>
func TestListAttestedNodesQuery(t *testing.T) {
for _, tt := range []struct {
dialect string
paged string
Copy link
Member

Choose a reason for hiding this comment

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

maybe having paged defined as a type is a better fit for this?

	type paged int

	const (
		no paged = iota
		withToken
		withNoToken
	)

expiresBefore := time.Now().Unix()
t.Run(name, func(t *testing.T) {
req := new(datastore.ListAttestedNodesRequest)
switch tt.paged {
Copy link
Member

Choose a reason for hiding this comment

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

I think that this switch could be more clear if it's done through a custom type.

Token: "2",
}
default:
require.FailNow(t, "unsupported page case: %q", tt.paged)
Copy link
Member

Choose a reason for hiding this comment

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

FailNowf should be used when using format strings.

req.FetchSelectors = true

default:
require.FailNow(t, "unsupported by case: %q", by)
Copy link
Member

Choose a reason for hiding this comment

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

FailNowf should be used when using format strings.

Token: "2",
}
default:
require.FailNow(t, "unsupported page case: %q", tt.paged)
Copy link
Member

Choose a reason for hiding this comment

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

nit: unsupported paged case

Signed-off-by: Marcos Yacob <marcos.yacob@hpe.com>
Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Thanks @MarcosDY!

@azdagron
Copy link
Member

azdagron commented Jul 1, 2020

CI/CD and DCO passed but it looks like there was a hiccup with notifications. Merging anyway.

@azdagron azdagron merged commit 65ef1d2 into spiffe:master Jul 1, 2020
@MarcosDY MarcosDY deleted the api-refactor-list-agents-query-test branch August 2, 2022 15:43
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.

None yet

3 participants