Skip to content

Commit 13839d1

Browse files
committed
# test update
1 parent bedf165 commit 13839d1

File tree

1 file changed

+2
-25
lines changed

1 file changed

+2
-25
lines changed

cmd/main_test.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,14 @@
11
package main
22

3-
import (
4-
"bytes"
5-
"net/http"
6-
"testing"
7-
)
3+
import "testing"
84

95
func Test_main(t *testing.T) {
10-
tests := []struct {
6+
var tests []struct {
117
name string
12-
}{
13-
{name: "Test case 1"},
148
}
159
for _, tt := range tests {
1610
t.Run(tt.name, func(t *testing.T) {
1711
main()
18-
jsonStr := []byte(`{"name":"Notebook Gamer","description":"Notebook para jogos","price":5999.99,"category":"Eletronicos"}`)
19-
req, err := http.NewRequest("POST", "http://localhost:8080/products", bytes.NewBuffer(jsonStr))
20-
if err != nil {
21-
t.Fatalf("Failed to create request: %v", err)
22-
}
23-
req.Header.Set("Content-Type", "application/json")
24-
25-
client := &http.Client{}
26-
resp, err := client.Do(req)
27-
if err != nil {
28-
t.Fatalf("Failed to send request: %v", err)
29-
}
30-
defer resp.Body.Close()
31-
32-
if resp.StatusCode != http.StatusOK {
33-
t.Errorf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode)
34-
}
3512
})
3613
}
3714
}

0 commit comments

Comments
 (0)