-
Notifications
You must be signed in to change notification settings - Fork 5
/
error_response_test.go
40 lines (32 loc) · 976 Bytes
/
error_response_test.go
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
32
33
34
35
36
37
38
39
40
package vagrant
import (
"testing"
)
const successfulErrorOutput = `
1534863784,default,metadata,provider,virtualbox
1534863784,default,action,halt,start
1534863784,default,ui,info,==> default: VM not created. Moving on...
1534863784,default,action,halt,end
`
const errorErrorOutput = `
1534347273,default,metadata,provider,virtualbox
1534347273,default,action,halt,start
1534347273,,error-exit,Vagrant::Errors::VBoxManageError,Some kind of error?
`
func TestErrorResponse_handleOutput(t *testing.T) {
parser := MockOutputParser{}
t.Run("success", func(t *testing.T) {
data := newErrorResponse()
parser.Run(successfulErrorOutput, &data)
if data.Error != nil {
t.Errorf("Successful vagrant command should not have set an error: %v", data.Error)
}
})
t.Run("error", func(t *testing.T) {
data := newErrorResponse()
parser.Run(errorErrorOutput, &data)
if data.Error == nil {
t.Errorf("There should have been an error, but there wasn't")
}
})
}