From d2ca19a88d4ba01f597c702843a53fcd004e3b40 Mon Sep 17 00:00:00 2001 From: elraphty Date: Fri, 14 Jun 2024 15:45:09 +0100 Subject: [PATCH] passed docker flow --- .github/workflows/prjob_tests.yml | 3 -- handlers/tribes_test.go | 49 ------------------------------- 2 files changed, 52 deletions(-) diff --git a/.github/workflows/prjob_tests.yml b/.github/workflows/prjob_tests.yml index 18e938047..c2bef0345 100644 --- a/.github/workflows/prjob_tests.yml +++ b/.github/workflows/prjob_tests.yml @@ -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 diff --git a/handlers/tribes_test.go b/handlers/tribes_test.go index b23c88e88..c6d984623 100644 --- a/handlers/tribes_test.go +++ b/handlers/tribes_test.go @@ -4,8 +4,6 @@ import ( "bytes" "context" "encoding/json" - "fmt" - "log" "net/http" "net/http/httptest" "strings" @@ -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)