Skip to content
Myr

Test for Persistent-Run propagation

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Anastasis Andronidis · committed by Anastasis Andronidis · parent 42e6ce3 · Browse files · 1 file+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−0 removed

  • other:+17 added−0 removed

1 file+17 added−0 removed

modified:cobra_test.go+17 added
867 unmodified lines
868 if echoPre != nil || echoPersPre != nil || timesPersPre != nil {869 t.Error("Wrong *Pre functions called!")870 }871}872873// Check if cmdEchoSub gets PersistentPreRun from rootCmd even if is added last874func TestPeristentPreRunPropagation(t *testing.T) {875 rootCmd := initialize()876877 // First add the cmdEchoSub to cmdPrint878 cmdPrint.AddCommand(cmdEchoSub)879 // Now add cmdPrint to rootCmd880 rootCmd.AddCommand(cmdPrint)881882 rootCmd.SetArgs(strings.Split("print echosub lala", " "))883 rootCmd.Execute()884885 if rootPersPre == nil || len(rootPersPre) == 0 || rootPersPre[0] != "lala" {886 t.Error("RootCmd PersistentPreRun not called but should have been")887 }888}