Skip to content

Commit

Permalink
Refactor daemon, add more tests (#1039)
Browse files Browse the repository at this point in the history
Refactors daemon cmd into separate, testable pieces.
  • Loading branch information
Eric-Warehime authored Jun 29, 2022
1 parent 997719a commit f3f1177
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 262 deletions.
11 changes: 5 additions & 6 deletions cmd/algorand-indexer/api_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var apiConfigCmd = &cobra.Command{
Long: "api configuration",
Run: func(cmd *cobra.Command, args []string) {
var err error
config.BindFlags(cmd)
config.BindFlagSet(cmd.Flags())
err = configureLogger()
if err != nil {
fmt.Fprintf(os.Stderr, "failed to configure logger: %v", err)
Expand All @@ -35,22 +35,21 @@ var apiConfigCmd = &cobra.Command{
panic(exit{1})
}

options := makeOptions()
var potentialDisabledMapConfig *api.DisabledMapConfig
if suppliedAPIConfigFile != "" {
potentialDisabledMapConfig, err := api.MakeDisabledMapConfigFromFile(swag, suppliedAPIConfigFile)
potentialDisabledMapConfig, err = api.MakeDisabledMapConfigFromFile(swag, suppliedAPIConfigFile)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to created disabled map config from file: %v", err)
panic(exit{1})
}
options.DisabledMapConfig = potentialDisabledMapConfig
}

var displayDisabledMapConfig *api.DisplayDisabledMap
// Show a limited subset
if !showAllDisabled {
displayDisabledMapConfig = api.MakeDisplayDisabledMapFromConfig(swag, options.DisabledMapConfig, true)
displayDisabledMapConfig = api.MakeDisplayDisabledMapFromConfig(swag, potentialDisabledMapConfig, true)
} else {
displayDisabledMapConfig = api.MakeDisplayDisabledMapFromConfig(swag, options.DisabledMapConfig, false)
displayDisabledMapConfig = api.MakeDisplayDisabledMapFromConfig(swag, potentialDisabledMapConfig, false)
}

output, err := displayDisabledMapConfig.String()
Expand Down
Loading

0 comments on commit f3f1177

Please sign in to comment.