Skip to content

Commit

Permalink
target channel is not unique
Browse files Browse the repository at this point in the history
  • Loading branch information
cfindlayisme committed May 23, 2024
1 parent 1a61865 commit a5102bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion webhook/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func SubscribePrivmsg(target string, url string) bool {
db := database.DB.GetDB()

// Create the table if it doesn't exist
_, err := db.Exec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions (Target TEXT PRIMARY KEY, URL TEXT, FailureCount INTEGER DEFAULT 0, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)")
_, err := db.Exec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions (Target TEXT, URL TEXT, FailureCount INTEGER DEFAULT 0, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (Target, URL))")
if err != nil {
log.Printf("Error creating table: %v", err)
return false
Expand Down
6 changes: 3 additions & 3 deletions webhook/subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestSubscribePrivmsg(t *testing.T) {
database.DB.SetDB(db)

// Expectations
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions \\(Target TEXT, URL TEXT, FailureCount INTEGER DEFAULT 0, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY \\(Target, URL\\)\\)").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectBegin()

// Expect the SELECT query
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestSubscribePrivmsgExistsAndDoesnt(t *testing.T) {
database.DB.SetDB(db)

// Expectations for the first call
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions \\(Target TEXT, URL TEXT, FailureCount INTEGER DEFAULT 0, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY \\(Target, URL\\)\\)").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectBegin()

// Expect the SELECT query
Expand All @@ -66,7 +66,7 @@ func TestSubscribePrivmsgExistsAndDoesnt(t *testing.T) {
require.False(t, result, "Expected false")

// Expectations for the second call
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectExec("CREATE TABLE IF NOT EXISTS PrivmsgSubscriptions \\(Target TEXT, URL TEXT, FailureCount INTEGER DEFAULT 0, Timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY \\(Target, URL\\)\\)").WillReturnResult(sqlmock.NewResult(1, 1))
mock.ExpectBegin()

// Expect the SELECT query
Expand Down

0 comments on commit a5102bc

Please sign in to comment.