diff options
Diffstat (limited to 'cmd/authelia-suites')
| -rw-r--r-- | cmd/authelia-suites/main.go | 23 | 
1 files changed, 22 insertions, 1 deletions
diff --git a/cmd/authelia-suites/main.go b/cmd/authelia-suites/main.go index 2ac03c3a2..4a75aff42 100644 --- a/cmd/authelia-suites/main.go +++ b/cmd/authelia-suites/main.go @@ -38,6 +38,12 @@ func main() {  		Run:   setupTimeoutSuite,  	} +	errorCmd := &cobra.Command{ +		Use:   "error [suite]", +		Short: "Run the OnError callback when some tests fail", +		Run:   runErrorCallback, +	} +  	stopCmd := &cobra.Command{  		Use:   "teardown [suite]",  		Short: "Teardown the suite environment", @@ -46,8 +52,11 @@ func main() {  	rootCmd.AddCommand(startCmd)  	rootCmd.AddCommand(setupTimeoutCmd) +	rootCmd.AddCommand(errorCmd)  	rootCmd.AddCommand(stopCmd) -	rootCmd.Execute() +	if err := rootCmd.Execute(); err != nil { +		log.Fatal(err) +	}  }  func createRunningSuiteFile(suite string) error { @@ -120,6 +129,18 @@ func setupTimeoutSuite(cmd *cobra.Command, args []string) {  	}  } +func runErrorCallback(cmd *cobra.Command, args []string) { +	suiteName := args[0] +	s := suites.GlobalRegistry.Get(suiteName) + +	if s.OnError == nil { +		return +	} +	if err := s.OnError(); err != nil { +		log.Fatal(err) +	} +} +  func teardownSuite(cmd *cobra.Command, args []string) {  	if os.Getenv("SKIP_TEARDOWN") != "" {  		return  | 
