Skip to content

Commit

Permalink
passed docker flow
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Jun 14, 2024
1 parent 2e27797 commit d2ca19a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/prjob_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
- name: Starting DB
run: docker compose -f ./docker/testdb-docker-compose.yml -p test_db up -d

- name: check container
run: docker container ls

- name: Install cover
run: go get golang.org/x/tools/cmd/cover

Expand Down
49 changes: 0 additions & 49 deletions handlers/tribes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"net/http/httptest"
"strings"
Expand Down Expand Up @@ -87,53 +85,6 @@ func TestGetTribesByOwner(t *testing.T) {
})
}

func setupSuite(_ *testing.T) func(tb testing.TB) {
db.InitTestDB()

return func(_ testing.TB) {
log.Println("Teardown test")
}
}

func TestGetPeopleReal(t *testing.T) {
teardownSuite := setupSuite(t)
defer teardownSuite(t)

tHandler := NewPeopleHandler(db.TestDB)
// Initialize test database connection and populate test data

// Create a request to your handler
req, err := http.NewRequest("GET", "/people", nil)
if err != nil {
t.Fatal(err)
}

// Create a ResponseRecorder to record the response
rr := httptest.NewRecorder()

// Create a Chi router and register your handler
r := chi.NewRouter()
r.Get("/people", tHandler.GetListedPeople)

// Serve the request to the handler
r.ServeHTTP(rr, req)

// Check the response status code
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusOK)
}

dbPeople := db.TestDB.GetListedPeople(req)

var returnedPersons []db.Person
err = json.Unmarshal(rr.Body.Bytes(), &returnedPersons)
assert.NoError(t, err)
fmt.Println("Returned People ==", returnedPersons)
assert.Equal(t, len(dbPeople), len(returnedPersons))
// Check the response body or any other expected behavior
}

func TestGetTribe(t *testing.T) {
mockDb := mocks.NewDatabase(t)
tHandler := NewTribeHandler(mockDb)
Expand Down

0 comments on commit d2ca19a

Please sign in to comment.