Skip to content

Commit

Permalink
# test update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulletdev committed Jan 18, 2025
1 parent bedf165 commit 13839d1
Showing 1 changed file with 2 additions and 25 deletions.
27 changes: 2 additions & 25 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
package main

import (
"bytes"
"net/http"
"testing"
)
import "testing"

func Test_main(t *testing.T) {
tests := []struct {
var tests []struct {
name string
}{
{name: "Test case 1"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
main()
jsonStr := []byte(`{"name":"Notebook Gamer","description":"Notebook para jogos","price":5999.99,"category":"Eletronicos"}`)
req, err := http.NewRequest("POST", "http://localhost:8080/products", bytes.NewBuffer(jsonStr))
if err != nil {
t.Fatalf("Failed to create request: %v", err)
}
req.Header.Set("Content-Type", "application/json")

client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
t.Fatalf("Failed to send request: %v", err)
}
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
t.Errorf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode)
}
})
}
}

0 comments on commit 13839d1

Please sign in to comment.