Skip to content

Commit

Permalink
feat: YIPEEEEE transactions now working :)
Browse files Browse the repository at this point in the history
  • Loading branch information
MintzyG committed Feb 23, 2024
1 parent 6cc15dd commit 40487a5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 2 additions & 1 deletion internal/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func MakeTransaction(ID int, req TransactionRequest) (Client, error) {
if ID < 1 || ID > 5 {
return client, echo.NewHTTPError(http.StatusNotFound, "not found")
}
client = clients[ID]
client = clients[ID - 1]

t, err := transactionRequestToTransaction(ID, req)
if err != nil {
Expand All @@ -57,6 +57,7 @@ func MakeTransaction(ID int, req TransactionRequest) (Client, error) {
return client, echo.NewHTTPError(http.StatusUnprocessableEntity, err.Error())
}

clients[ID - 1] = client
return client, nil
}

Expand Down
6 changes: 3 additions & 3 deletions load-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function validarConsistenciaSaldoLimite(response) {
return saldo >= -1 * limite;
}

const baseUrl = 'http://localhost:9999';
const baseUrl = 'http://localhost:4000';

export let options = {
scenarios: {
Expand All @@ -59,7 +59,7 @@ export let options = {
gracefulRampDown: '60s',
exec: 'debitos',
},
extratos: {
/* extratos: {
executor: 'ramping-vus',
startVUs: 0,
stages: [
Expand All @@ -68,7 +68,7 @@ export let options = {
],
gracefulRampDown: '60s',
exec: 'extratos',
},
}, */
},
};

Expand Down
10 changes: 1 addition & 9 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package main

import (
"encoding/json"
"flag"
"fmt"
"net/http"
"strconv"

Expand Down Expand Up @@ -50,11 +48,5 @@ func handleTransaction(c echo.Context) error {
response.Saldo = cc.Balance
response.Limite = cc.MaxLimit

body, err := json.Marshal(response)
if err != nil {
return c.JSON(http.StatusUnprocessableEntity, "marshal response")
}

fmt.Println(string(body))
return c.JSON(http.StatusOK, body)
return c.JSON(http.StatusOK, response)
}

0 comments on commit 40487a5

Please sign in to comment.