We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stakwork Run
File: /tmp/stakwork/sphinx-tribes/db/db.go
package db import ( "testing" "github.com/stretchr/testify/assert" "gorm.io/driver/sqlite" "gorm.io/gorm" ) // Mock database setup func setupTestDB() *gorm.DB { db, _ := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{}) db.AutoMigrate(&Bounty{}) return db } func TestGetFilterStatusCount(t *testing.T) { tests := []struct { name string bounties []Bounty expected FilterStattuCount }{ { name: "Standard Case with Mixed Statuses", bounties: []Bounty{ {Show: true, Assignee: "", Paid: false}, {Show: true, Assignee: "user1", Paid: false}, {Show: true, Assignee: "user2", Completed: true, Paid: false}, {Show: true, Assignee: "user3", Paid: true}, {Show: true, Assignee: "user4", PaymentPending: true}, {Show: true, Assignee: "user5", PaymentFailed: true}, }, expected: FilterStattuCount{Open: 1, Assigned: 1, Completed: 1, Paid: 1, Pending: 1, Failed: 1}, }, { name: "All Records Hidden", bounties: []Bounty{{Show: false}, {Show: false}}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 0, Pending: 0, Failed: 0}, }, { name: "No Assignees", bounties: []Bounty{{Show: true, Assignee: ""}, {Show: true, Assignee: ""}}, expected: FilterStattuCount{Open: 2, Assigned: 0, Completed: 0, Paid: 0, Pending: 0, Failed: 0}, }, { name: "All Paid", bounties: []Bounty{{Show: true, Paid: true}, {Show: true, Paid: true}}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 2, Pending: 0, Failed: 0}, }, { name: "All Completed but Not Paid", bounties: []Bounty{{Show: true, Completed: true, Paid: false}, {Show: true, Completed: true, Paid: false}}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 2, Paid: 0, Pending: 0, Failed: 0}, }, { name: "All Payment Pending", bounties: []Bounty{{Show: true, PaymentPending: true}, {Show: true, PaymentPending: true}}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 0, Pending: 2, Failed: 0}, }, { name: "All Payment Failed", bounties: []Bounty{{Show: true, PaymentFailed: true}, {Show: true, PaymentFailed: true}}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 0, Pending: 0, Failed: 2}, }, { name: "Empty Database", bounties: []Bounty{}, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 0, Pending: 0, Failed: 0}, }, { name: "Single Record for Each Status", bounties: []Bounty{ {Show: true, Assignee: "", Paid: false}, {Show: true, Assignee: "user1", Paid: false}, {Show: true, Assignee: "user2", Completed: true, Paid: false}, {Show: true, Assignee: "user3", Paid: true}, {Show: true, Assignee: "user4", PaymentPending: true}, {Show: true, Assignee: "user5", PaymentFailed: true}, }, expected: FilterStattuCount{Open: 1, Assigned: 1, Completed: 1, Paid: 1, Pending: 1, Failed: 1}, }, { name: "All Conditions False", bounties: []Bounty{ {Show: false, Assignee: "", Paid: false}, {Show: false, Assignee: "", Paid: false}, }, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 0, Paid: 0, Pending: 0, Failed: 0}, }, { name: "Mixed Conditions with Overlapping Criteria", bounties: []Bounty{ {Show: true, Assignee: "user1", Completed: true, PaymentPending: true, Paid: false}, {Show: true, Assignee: "user2", Completed: true, PaymentFailed: true, Paid: false}, }, expected: FilterStattuCount{Open: 0, Assigned: 0, Completed: 2, Paid: 0, Pending: 1, Failed: 1}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { db := setupTestDB() for _, bounty := range tt.bounties { db.Create(&bounty) } database := database{db: db} result := database.GetFilterStatusCount() assert.Equal(t, tt.expected, result) }) } }
The text was updated successfully, but these errors were encountered:
@tomsmith8 assign?
Sorry, something went wrong.
@tomsmith8 Please assign me?
@tomsmith8 can i help?
sophieturner0
Successfully merging a pull request may close this issue.
Unit Test Coverage for "GetFilterStatusCount"
Stakwork Run
Unit Test Code
File: /tmp/stakwork/sphinx-tribes/db/db.go
The text was updated successfully, but these errors were encountered: