Skip to content
New issue

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

horizon/integration/test: added test for reingest with --ledgerbackend datastore #5383

Merged
merged 14 commits into from
Jul 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#4911: use rootcmd instance not package singleton in tests
  • Loading branch information
sreuland committed Jul 12, 2024
commit 9981bac99f5be78a5efb148d07f0fd156c69f130
24 changes: 5 additions & 19 deletions services/horizon/cmd/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ type DBCommandsTestSuite struct {
rootCmd *cobra.Command
}

func (s *DBCommandsTestSuite) SetupTest() {
resetFlags()
}

func resetFlags() {
RootCmd.ResetFlags()
dbFillGapsCmd.ResetFlags()
dbReingestRangeCmd.ResetFlags()

globalFlags.Init(RootCmd)
dbFillGapsCmdOpts.Init(dbFillGapsCmd)
dbReingestRangeCmdOpts.Init(dbReingestRangeCmd)
}

func (s *DBCommandsTestSuite) SetupSuite() {
runDBReingestRangeFn = func([]history.LedgerRange, bool, uint,
horizon.Config, ingest.StorageBackendConfig) error {
Expand Down Expand Up @@ -258,21 +244,21 @@ func (s *DBCommandsTestSuite) TestDbReingestAndFillGapsCmds() {
for _, command := range commands {
for _, tt := range tests {
s.T().Run(tt.name+"_"+command.name, func(t *testing.T) {
resetFlags()

rootCmd := NewRootCmd()
var args []string
args = append(command.cmd, tt.args...)
RootCmd.SetArgs(append([]string{
"--db-url", s.dsn,
rootCmd.SetArgs(append([]string{
"--db-url", s.db.DSN,
"--stellar-core-binary-path", "/test/core/bin/path",
}, args...))

if tt.expectError {
err := RootCmd.Execute()
err := rootCmd.Execute()
require.Error(t, err)
require.Contains(t, err.Error(), tt.errorMessage)
} else {
require.NoError(t, RootCmd.Execute())
require.NoError(t, rootCmd.Execute())
}
})
}
Expand Down
Loading