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

Simplify tests with gabs? #91

Open
bfabio opened this issue Jul 21, 2022 · 1 comment
Open

Simplify tests with gabs? #91

bfabio opened this issue Jul 21, 2022 · 1 comment
Labels
nice-to-have Nice to have feature or improvement

Comments

@bfabio
Copy link
Member

bfabio commented Jul 21, 2022

Writing tests in validationFunc can be annoying. We can consider using https://github.com/Jeffail/gabs to reduce the boilerplate.

@bfabio bfabio added the nice-to-have Nice to have feature or improvement label Jul 21, 2022
@LorenzoS92
Copy link
Contributor

LorenzoS92 commented Oct 4, 2022

Tried gabs succesfully in GET with page[size] query param

Test code:

jsonParsed.Exists("data")
assert.Equal(t, 2, len(jsonParsed.S("data").Children()))

jsonParsed.Exists("links")

value := jsonParsed.Path("links.prev").Data()
assert.Nil(t, value)

value, ok := jsonParsed.Path("links.next").Data().(string)
if ok {
	assert.Equal(t, "?page[after]=WyIyMDE4LTA1LTE2VDAwOjAwOjAwWiIsIjQ3ODA3ZTBjLTA2MTMtNGFlYS05OTE3LTU0NTVjYzZlZGRhZCJd", value)
} else {
	assert.FailNow(t, "Invalid links.prev.next")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nice-to-have Nice to have feature or improvement
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants