From b4ec6e2ed2d751d5a1c3b4f023f3256747b8fbe8 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Thu, 14 Mar 2019 13:32:46 +0100 Subject: [PATCH] Create exit_code_test.go --- common/shell/exit_code_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 common/shell/exit_code_test.go diff --git a/common/shell/exit_code_test.go b/common/shell/exit_code_test.go new file mode 100644 index 000000000..c0ce58e99 --- /dev/null +++ b/common/shell/exit_code_test.go @@ -0,0 +1,31 @@ +package shell + +import ( + "fmt" + "testing" +) + +func TestProvisioner_ValidExitCode(t *testing.T) { + + tests := []struct { + exitCodes []int + code int + wantErr bool + }{ + {nil, 0, false}, + {nil, 1, true}, + {[]int{2}, 2, false}, + {[]int{2}, 3, true}, + } + for n := range tests { + tt := tests[n] + t.Run(fmt.Sprintf("%v - %v - %v", tt.exitCodes, tt.code, tt.wantErr), func(t *testing.T) { + p := Provisioner{ + ValidExitCodes: tt.exitCodes, + } + if err := p.ValidExitCode(tt.code); (err != nil) != tt.wantErr { + t.Errorf("Provisioner.ValidExitCode() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +}