package application import ( "context" "os" "path/filepath" "testing" ) func TestApplicationSupportsMultipleDevicesAndGracefulShutdown(t *testing.T) { configPath := filepath.Join(t.TempDir(), "config.yaml") config := []byte(`host: 127.0.0.1 port: 9090 logLevel: 4 shelly: timeoutSeconds: 1 devices: - name: office product: plug_s url: http://192.0.2.1 - name: kitchen product: plug_s url: http://192.0.2.2 `) if err := os.WriteFile(configPath, config, 0o600); err != nil { t.Fatal(err) } app, err := New(configPath) if err != nil { t.Fatalf("New() returned an unexpected error: %v", err) } app.server.Addr = "127.0.0.1:0" ctx, cancel := context.WithCancel(context.Background()) cancel() if err := app.Run(ctx); err != nil { t.Fatalf("Run() returned an unexpected error: %v", err) } }