Skip to content

Commit

Permalink
fix: parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
dalssoft committed Oct 25, 2022
1 parent 5c41512 commit 60de48c
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 138 deletions.
9 changes: 5 additions & 4 deletions src/commands/assist.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ const command = {
model = "code-davinci-002",
codexPrompt,
temperature = 0.3,
max_tokens = 2000,
max_tokens = 3000,
top_p = 1,
best_of = 3,
best_of = 1,
frequency_penalty = 0.04,
presence_penalty = 0.01,
stop = ["END"],
Expand Down Expand Up @@ -362,12 +362,13 @@ const command = {
return choices[0].text
}


function parseResponse(codexResponse) {
const regex = /~~~~([\s\S]*?)~~~~/gm
const regex = /~~~~([\s\S]*)/gm
const ret = regex.exec(codexResponse)

// check if processed spec if valid
if (ret === null || ret[1].length < 1) throw Error(`Spec not generated duo to parsing error`)
if (ret === null || ret[1].length < 1) throw Error(`It was not possible to parse the response from OpenAI`)

const response = ret[1]
return response.trim()
Expand Down
3 changes: 0 additions & 3 deletions src/templates/assist/scenarios.md.codex.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Scenario: A project should not be created if the project is not valid
Given an invalid project
When the project is created
Then the project is not created on the repository
~~~~
END

Group: Reservation
Expand All @@ -35,7 +34,6 @@ Scenario: A reservation should not be updated if customer is inactive
Given a customer is inactive and reservation is valid
When the reservation is updated
Then the reservation is not updated on the repository
~~~~
END

Group: Payment
Expand All @@ -55,7 +53,6 @@ Scenario: Payment status can not be changed if payment is more than 30 days old
Given a payment with status not paid and more than 30 days old
When the payment status is changed
Then the payment status is not changed on the repository
~~~~
END

Group: <%- props.usecaseGroup %>
Expand Down
1 change: 0 additions & 1 deletion src/templates/assist/spec.codex.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ module.exports =
.add(updateUserSpec, 'UpdateUserSpec')
.metadata({ usecase: 'UpdateUser' })
.spec
~~~~
END

<%- props.scenarios %>
Expand Down
2 changes: 0 additions & 2 deletions src/templates/assist/usecase.codex.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ module.exports =
.add(updateUser, 'UpdateUser')
.metadata({ group: 'User', operation: herbarium.crud.update, entity: User })
.usecase
~~~~
END

Example: `Find User`
Expand Down Expand Up @@ -298,7 +297,6 @@ module.exports =
.add(findUser, 'FindUser')
.metadata({ group: 'User', operation: herbarium.crud.read, entity: User })
.usecase
~~~~
END

Example: `<%- props.usecaseName %>`
Expand Down
2 changes: 1 addition & 1 deletion src/templates/infra/api/rest/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function rest(app, config) {
// controllers.push({
// name: 'Search',
// post: {
// usecase: herbarium.usecases.get('SearchTask'),
// usecase: herbarium.usecases.get('SearchTask').usecase,
// controller: searchController
// }
// })
Expand Down
25 changes: 25 additions & 0 deletions src/tests/assist/scenarios/Create Reservation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Usecase: Create Reservation
Scenario: A reservation should be created if the reservation is valid
Given a valid reservation
When the reservation is created
Then the reservation is created on the repository

Scenario: A reservation should not be created if the reservation has an invalid initial date
Given an reservation with an invalid initial date
When the reservation is created
Then the reservation is not created on the repository

Scenario: A reservation should not be created if the reservation has an invalid final date
Given an reservation with an invalid final date
When the reservation is created
Then the reservation is not created on the repository

Scenario: A reservation should not be created if the reservation has no customer
Given an reservation with no customer
When the reservation is created
Then the reservation is not created on the repository

Scenario: A reservation should not be created if the reservation has no room
Given an reservation with no room
When the reservation is created
Then the reservation is not created on the repository
30 changes: 30 additions & 0 deletions src/tests/assist/scenarios/Create Ticket.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Usecase: Create Ticket
Scenario: A ticket should be created if the ticket is valid
Given a valid ticket
When the ticket is created
Then the ticket is created on the repository

Scenario: A ticket should not be created if the ticket does not have a title
Given a ticket without a title
When the ticket is created
Then the ticket is not created on the repository

Scenario: A ticket should not be created if the ticket does not have a user
Given a ticket without a user
When the ticket is created
Then the ticket is not created on the repository

Scenario: A ticket should not be created if the ticket does not have a description
Given a ticket without a description
When the ticket is created
Then the ticket is not created on the repository

Scenario: A ticket should not be created if the ticket does not have a priority
Given a ticket without a priority
When the ticket is created
Then the ticket is not created on the repository

Scenario: A ticket should not be created if the ticket does not have a status
Given a ticket without a status
When the ticket is created
Then the ticket is not created on the repository
20 changes: 20 additions & 0 deletions src/tests/assist/scenarios/Remove All User's Permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Usecase: Remove All User's Permissions
Scenario: All user's permissions should be removed if user is active
Given an active user
When all user's permissions are removed
Then all user's permissions are removed on the repository

Scenario: All user's permissions should not be removed if user is inactive
Given an inactive user
When all user's permissions are removed
Then all user's permissions are not removed on the repository

Scenario: All user's permissions should not be removed if user has no permissions
Given an active user with no permissions
When all user's permissions are removed
Then all user's permissions are not removed on the repository

Scenario: All user's permissions should not be removed if user is owner
Given an active user with owner permissions
When all user's permissions are removed
Then all user's permissions are not removed on the repository
127 changes: 0 additions & 127 deletions tmp/spec.codex

This file was deleted.

0 comments on commit 60de48c

Please sign in to comment.