Skip to content

Commit

Permalink
Merge pull request stakwork#1768 from AbdulWahab3181/Refactor-TestGet…
Browse files Browse the repository at this point in the history
…TribesByAppUrl-UT

Refactor TestGetTribesByAppUrl To Use A Real Postgres DB For The Test
  • Loading branch information
elraphty authored Jun 26, 2024
2 parents eea77b7 + 62fb62f commit 4f6109b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions handlers/tribes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,26 @@ func TestGetTribe(t *testing.T) {
}

func TestGetTribesByAppUrl(t *testing.T) {
mockDb := mocks.NewDatabase(t)
tHandler := NewTribeHandler(mockDb)
teardownSuite := SetupSuite(t)
defer teardownSuite(t)

tHandler := NewTribeHandler(db.TestDB)

t.Run("Should test that a tribe is returned when the right app URL is passed", func(t *testing.T) {
// Mock data
mockAppURL := "valid_app_url"
mockTribes := []db.Tribe{
{UUID: "uuid", AppURL: mockAppURL},
{UUID: "uuid", AppURL: mockAppURL},
tribe := db.Tribe{
UUID: "uuid",
OwnerPubKey: "pubkey",
Name: "name",
Description: "description",
Tags: []string{"tag3", "tag4"},
AppURL: "valid_app_url",
Badges: []string{},
}
mockDb.On("GetTribesByAppUrl", mockAppURL).Return(mockTribes).Once()
db.TestDB.CreateOrEditTribe(tribe)

// Mock data
mockAppURL := tribe.AppURL
mockTribes := []db.Tribe{tribe}

// Serve request
rr := httptest.NewRecorder()
Expand Down

0 comments on commit 4f6109b

Please sign in to comment.