Skip to content

Commit 2740516

Browse files
committed
# Refatorar e testes unitarios
1 parent 8868a9d commit 2740516

File tree

8 files changed

+43
-29
lines changed

8 files changed

+43
-29
lines changed

api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const API_URL = 'http://localhost:8080'; //url do app, vou add dps
1+
const API_URL = 'http://localhost:4444'; //url do app, vou add dps
22

33
export const productService = {
44
async getProducts() {

bullet.env

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"strings"
6+
)
17

28
type Config struct {
39
Port string
@@ -11,4 +17,4 @@ func LoadConfig() Config {
1117
CorsOrigins: strings.Split(os.Getenv("CORS_ORIGINS"), ","),
1218
DbURL: os.Getenv("DATABASE_URL"),
1319
}
14-
}
20+
}

cmd/main_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ func Test_main(t *testing.T) {
66
tests := []struct {
77
name string
88
}{
9-
// TODO: Add test cases.
9+
{name: "Test case 1"},
10+
{name: "Test case 2"},
1011
}
1112
for _, tt := range tests {
1213
t.Run(tt.name, func(t *testing.T) {

docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
api:
55
build: .
66
ports:
7-
- "8080:8080"
7+
- "4444:4444"
88
environment:
9-
- API_PORT=8080
9+
- API_PORT=4444
1010
- CORS_ORIGINS=

dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine
1+
FROM golang:1.24-rc-alpine3.21
22

33
WORKDIR /app
44
COPY . .

internal/models/product.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"fmt"
66
"sync"
77
)
8-
8+
99
type Product struct {
1010
ID string `json:"id"`
1111
Name string `json:"name"`
@@ -19,7 +19,7 @@ type ProductRepository struct {
1919
products map[string]Product
2020
counter int
2121
}
22-
// bulletdev
22+
2323
func NewProductRepository() *ProductRepository {
2424
return &ProductRepository{
2525
products: make(map[string]Product),
@@ -71,7 +71,7 @@ func (r *ProductRepository) Update(id string, updatedProduct Product) error {
7171
r.products[id] = updatedProduct
7272
return nil
7373
}
74-
// bulletdev
74+
7575
func (r *ProductRepository) Delete(id string) error {
7676
r.mu.Lock()
7777
defer r.mu.Unlock()

readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Tratamento seguro de concorrência
3838
Endpoints RESTful
3939
</div>
4040

41+
<div>
4142
Health check
4243
</div>
4344

@@ -46,12 +47,19 @@ Testes Unitários
4647

4748
</div>
4849

50+
🚀 Exemplo de uso
51+
52+
```bash
53+
Invoke-WebRequest -Uri http://localhost:4444/products -Method POST -Headers @{"Content-Type"="application/json"} -Body '{"name":"Notebook Gamer","description":"Notebook para jogos","price":5999.99,"category":"Eletronicos"}'
54+
```
55+
4956
## demonstração:
5057

5158
<details>
5259
<img src="/demo.png">
5360
</details>
5461

62+
5563
🛠 Tecnologias
5664

5765
<div>

render.yaml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# Exported from Render on 2024-12-05T20:29:12Z
21
services:
3-
- type: web
4-
name: bullet-cloud-api
5-
runtime: go
6-
repo: https://github.com/Bulletdev/bullet-cloud-api
7-
plan: free
8-
envVars:
9-
- key: DbURL
10-
sync: false
11-
- key: CorsOrigins
12-
sync: false
13-
- key: Port
14-
sync: false
15-
- key: test
16-
sync: false
17-
region: ohio
18-
buildCommand: go mod tidy
19-
startCommand: go run cmd/main.go
20-
autoDeploy: false
21-
version: "1"
2+
- type: web
3+
name: bullet-cloud-api
4+
runtime: go
5+
repo: https://github.com/Bulletdev/bullet-cloud-api
6+
plan: free
7+
envVars:
8+
- key: DbURL
9+
sync: false
10+
- key: CorsOrigins
11+
sync: false
12+
- key: Port
13+
sync: false
14+
- key: test
15+
sync: false
16+
region: ohio
17+
buildCommand: go mod tidy
18+
startCommand: go run cmd/main.go
19+
autoDeploy: false
20+
version: "1"

0 commit comments

Comments
 (0)