(t *testing.T)
| 3 | import "testing" |
| 4 | |
| 5 | func TestExecCommand(t *testing.T) { |
| 6 | type args struct { |
| 7 | command string |
| 8 | options []string |
| 9 | silentMode bool |
| 10 | } |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | args args |
| 14 | wantErr bool |
| 15 | }{ |
| 16 | { |
| 17 | "successfully executing command", |
| 18 | args{ |
| 19 | command: "echo", |
| 20 | options: []string{"ping"}, |
| 21 | silentMode: false, |
| 22 | }, |
| 23 | false, |
| 24 | }, |
| 25 | { |
| 26 | "successfully executing command with silent mode", |
| 27 | args{ |
| 28 | command: "echo", |
| 29 | options: []string{"ping"}, |
| 30 | silentMode: true, |
| 31 | }, |
| 32 | false, |
| 33 | }, |
| 34 | { |
| 35 | "failed executing command", |
| 36 | args{}, |
| 37 | true, |
| 38 | }, |
| 39 | } |
| 40 | for _, tt := range tests { |
| 41 | t.Run(tt.name, func(t *testing.T) { |
| 42 | if err := ExecCommand(tt.args.command, tt.args.options, tt.args.silentMode); (err != nil) != tt.wantErr { |
| 43 | t.Errorf("ExecCommand() error = %v, wantErr %v", err, tt.wantErr) |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | } |
nothing calls this directly
no test coverage detected