summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorLibravatar tobi <tobi.smethurst@protonmail.com>2025-07-09 17:25:45 +0200
committerLibravatar tobi <kipvandenbos@noreply.codeberg.org>2025-07-09 17:25:45 +0200
commit352353ce7a33c3ac26fbecd597ab24ae2f9c9864 (patch)
treeeeea288eea02162ff25e54c9052eaffd705cb5ad /cmd
parent[feature] Use `hidesToPublicFromUnauthedWeb` and `hidesCcPublicFromUnauthedWe... (diff)
downloadgotosocial-352353ce7a33c3ac26fbecd597ab24ae2f9c9864.tar.xz
[chore/testing] Add env vars to skip testrig setup/teardown (#4317)
Add flags to skip local testrig db setup and teardown, to allow somewhat easier testing of migrations. Documents env vars available to the testrig. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4317 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gotosocial/action/testrig/testrig.go12
-rw-r--r--cmd/gotosocial/testrig.go2
2 files changed, 12 insertions, 2 deletions
diff --git a/cmd/gotosocial/action/testrig/testrig.go b/cmd/gotosocial/action/testrig/testrig.go
index 6010d4047..2b70a3447 100644
--- a/cmd/gotosocial/action/testrig/testrig.go
+++ b/cmd/gotosocial/action/testrig/testrig.go
@@ -92,9 +92,14 @@ var Start action.GTSAction = func(ctx context.Context) error {
}
if state.DB != nil {
+ // Clean up database by
+ // dropping tables if required.
+ if !config.GetTestrigSkipDBTeardown() {
+ testrig.StandardDBTeardown(state.DB)
+ }
+
// Lastly, if database service was started,
// ensure it gets closed now all else stopped.
- testrig.StandardDBTeardown(state.DB)
if err := state.DB.Close(); err != nil {
log.Errorf(ctx, "error stopping database: %v", err)
}
@@ -125,7 +130,10 @@ var Start action.GTSAction = func(ctx context.Context) error {
// that twice, we can just start the initialized caches.
state.Caches.Start()
- testrig.StandardDBSetup(state.DB, nil)
+ // Populate database tables + data if required.
+ if !config.GetTestrigSkipDBSetup() {
+ testrig.StandardDBSetup(state.DB, nil)
+ }
// Get the instance account (we'll need this later).
instanceAccount, err := state.DB.GetInstanceAccount(ctx, "")
diff --git a/cmd/gotosocial/testrig.go b/cmd/gotosocial/testrig.go
index ee21b7312..55498243b 100644
--- a/cmd/gotosocial/testrig.go
+++ b/cmd/gotosocial/testrig.go
@@ -19,6 +19,7 @@ package main
import (
"code.superseriousbusiness.org/gotosocial/cmd/gotosocial/action/testrig"
+ "code.superseriousbusiness.org/gotosocial/internal/config"
"github.com/spf13/cobra"
)
@@ -38,6 +39,7 @@ func testrigCommands() *cobra.Command {
}
testrigCmd.AddCommand(testrigStartCmd)
+ config.AddTestrig(testrigCmd)
return testrigCmd
}
return nil