From 35d2d8af5b210283d946891495570cb5a9912e1b Mon Sep 17 00:00:00 2001 From: Luca Bernstein Date: Mon, 14 Nov 2022 17:31:58 +0100 Subject: [PATCH] Fix user settings available for omitLeadingSlash (#198) --- db/migrations/controller.go | 1 + db/migrations/v12.go | 21 +++++++++++++++++++++ scenarioTests/features/config.feature | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 db/migrations/v12.go create mode 100644 scenarioTests/features/config.feature diff --git a/db/migrations/controller.go b/db/migrations/controller.go index 8218b0a..22444fb 100644 --- a/db/migrations/controller.go +++ b/db/migrations/controller.go @@ -22,6 +22,7 @@ func Migrate(db *sql.DB) { migrationWrapper(v9, 9)(db) migrationWrapper(v10, 10)(db) migrationWrapper(v11, 11)(db) + migrationWrapper(v12, 12)(db) helpers.LogLocalf(helpers.INFO, nil, "Migrations ran through. Schema version: %d", schema(db)) } diff --git a/db/migrations/v12.go b/db/migrations/v12.go new file mode 100644 index 0000000..4505f52 --- /dev/null +++ b/db/migrations/v12.go @@ -0,0 +1,21 @@ +package migrations + +import ( + "database/sql" + "log" +) + +func v12(db *sql.Tx) { + v12AddLeadingSlashSetting(db) +} + +func v12AddLeadingSlashSetting(db *sql.Tx) { + sqlStatement := ` + INSERT INTO "bot::userSettingTypes" ("setting", "description") VALUES + ('user.omitCommandSlash', 'make leading slash for commands optional'); + ` + _, err := db.Exec(sqlStatement) + if err != nil { + log.Fatal(err) + } +} diff --git a/scenarioTests/features/config.feature b/scenarioTests/features/config.feature new file mode 100644 index 0000000..5e6dc05 --- /dev/null +++ b/scenarioTests/features/config.feature @@ -0,0 +1,7 @@ +Feature: config user settings + + Scenario: test config command handling + Given I have a bot + When I send the message "/config omit_slash on" + Then 1 messages should be sent back + And the response should include the message "has successfully been turned on"