(t *testing.T)
| 2652 | } |
| 2653 | |
| 2654 | func TestSetContextPreRunOverwrite(t *testing.T) { |
| 2655 | type key struct{} |
| 2656 | val := "blah" |
| 2657 | root := &Command{ |
| 2658 | Use: "root", |
| 2659 | Run: func(cmd *Command, args []string) { |
| 2660 | key := cmd.Context().Value(key{}) |
| 2661 | _, ok := key.(string) |
| 2662 | if ok { |
| 2663 | t.Error("key found in context when not expected") |
| 2664 | } |
| 2665 | }, |
| 2666 | } |
| 2667 | ctx := context.WithValue(context.Background(), key{}, val) |
| 2668 | root.SetContext(ctx) |
| 2669 | err := root.ExecuteContext(context.Background()) |
| 2670 | if err != nil { |
| 2671 | t.Error(err) |
| 2672 | } |
| 2673 | } |
| 2674 | |
| 2675 | func TestSetContextPersistentPreRun(t *testing.T) { |
| 2676 | type key struct{} |
nothing calls this directly
no test coverage detected
searching dependent graphs…