Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/main/resources/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2111,8 +2111,12 @@ components:
type: object
properties:
searchTerm:
minLength: 3
maxLength: 100
description: must not be null, and must be at least three characters long to avoid an exception
type: string
includeAll:
description: must not be null
type: boolean
GraphQLSetProjectLocationRequest:
type: object
Expand Down
19 changes: 19 additions & 0 deletions core/src/test/groovy/org/justserve/GraphQLClientSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,23 @@ class GraphQLClientSpec extends Specification {
noExceptionThrown()
!response.hasErrors()
}

def "test searchOrganization parses the input correctly"(String searchTerm, Boolean includesAll) {
given:

GraphQLSearchOrganizationVariables inputData = new GraphQLSearchOrganizationVariables()
.setSearchTerm(searchTerm)
.setIncludeAll(includesAll)

when:
GraphQLResponse<GraphQLSearchOrganizationData> response = client.searchOrganization(inputData)

then:
noExceptionThrown()
!response.hasErrors()

where:
[includesAll, searchTerm] << [[true, false], ["the"]].combinations()

}
}
18 changes: 7 additions & 11 deletions core/src/test/groovy/org/justserve/JustServeSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@ class JustServeSpec extends Specification {
// }
ctx = ApplicationContext.builder()
.environments(Environment.CLI, Environment.TEST)
.properties([
"justserve.token": System.getenv("TEST_TOKEN")
])
.properties(["justserve.token": System.getenv("TEST_TOKEN")])
.build()
.start()
noAuthCtx = ApplicationContext
.builder()
.environments(Environment.CLI, Environment.TEST)
.environmentVariableExcludes("JUSTSERVE_TOKEN")
.properties(["justserve.token": ""])
.build()
.start()
noAuthUserClient = noAuthCtx.getBean(UserClient)
Expand Down Expand Up @@ -107,14 +106,13 @@ class JustServeSpec extends Specification {
HttpResponse<CreateUser200Response> createUser(UserClient client = noAuthUserClient) {
HttpResponse<CreateUser200Response> response = null
def tries = 0
while ((null == response || HttpStatus.OK != response.status()) && tries < 5) {
while ((null == response || ![HttpStatus.OK, HttpStatus.CREATED].contains(response.status())) && tries < 5) {
try {
// A new user is generated on each loop iteration to avoid collisions
response = createUserFromFaker(client, new TestUser(new Faker(Locale.of("en-us"))))
} catch (HttpClientResponseException ignored) {
tries++
// This user likely already exists, so we'll loop and try a new one.
}
tries++
}
if (null == response) {
throw new IllegalStateException("failed to create a test user after five attempts")
Expand Down Expand Up @@ -161,7 +159,7 @@ class JustServeSpec extends Specification {
.setContactPhone(faker.phoneNumber().phoneNumber())
.setDescription(faker.zelda().game())
.setLocationString(knownWorkingLocation)
.setLogo(getUploadedImageFileName())
.setLogo(null)
.setName(faker.zelda().character())
.set_public(null)
.setUrl(getUniqueSlug())
Expand Down Expand Up @@ -196,9 +194,7 @@ class JustServeSpec extends Specification {
* @return The file name of the uploaded image.
*/
String getUploadedImageFileName() {
HttpResponse<ImageUploadResponse> profileImage = authImageClient.uploadImage(
new ImageUploadRequest(faker.image().base64JPG().split(",")[1], 256, 256, false, 0, 0)
)
HttpResponse<ImageUploadResponse> profileImage = authImageClient.uploadImage(new ImageUploadRequest(faker.image().base64JPG().split(",")[1], 256, 256, false, 0, 0))
return profileImage.body().displayFileName
}

Expand All @@ -209,7 +205,7 @@ class JustServeSpec extends Specification {
String getUniqueSlug() {
String urlSlug = null
while (null == urlSlug) {
def potentialSlug = faker.word().noun()
def potentialSlug = faker.word().noun() + System.currentTimeMillis()
def response = authDynamicRoutingClient.getOrgIdFromSlug(potentialSlug)
if (response.status() == HttpStatus.NOT_FOUND) {
urlSlug = potentialSlug
Expand Down
Loading