Skip to content

Instantly share code, notes, and snippets.

@madflojo
Last active May 13, 2022 15:36
Show Gist options
  • Save madflojo/f70c8d6dd0962002e31396825d5b7bad to your computer and use it in GitHub Desktop.
Save madflojo/f70c8d6dd0962002e31396825d5b7bad to your computer and use it in GitHub Desktop.
Go Project Structure - Testing App
func TestRunningServer(t *testing.T) {
cfg := viper.New()
cfg.Set("disable_logging", true)
cfg.Set("listen_addr", "localhost:9000")
cfg.Set("kvstore_type", "redis")
cfg.Set("redis_server", "redis:6379")
cfg.Set("enable_kvstore", true)
cfg.Set("debug", true)
cfg.Set("trace", true)
go func() {
err := Run(cfg)
if err != nil && err != ErrShutdown {
t.Errorf("Run unexpectedly stopped - %s", err)
}
}()
// Clean up
defer Stop()
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment