File: exit_code_test.go

package info (click to toggle)
packer 1.6.6%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 33,156 kB
  • sloc: sh: 1,154; python: 619; makefile: 251; ruby: 205; xml: 97
file content (31 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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)
			}
		})
	}
}