-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_fail_test.go
46 lines (34 loc) · 1.12 KB
/
main_fail_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
41
42
43
44
45
46
package main
import (
"errors"
"testing"
)
func TestShowingTheErrorWhenKubectlFails(t *testing.T) {
mockKubectl := new(MockKubectl)
mockKubectl.On("getRolloutHistory", "deployment", "nginx-that-does-not-exist", "").Return("", errors.New("error"))
mockWriter := new(MockWriter)
namespace := ""
_, err := mainLogic(mockKubectl, mockWriter, namespace, []string{"deployment/nginx-that-does-not-exist"})
if err == nil {
t.Errorf("Expected error")
}
}
func TestFailingWhenResourceNameIsNotSpecified(t *testing.T) {
mockKubectl := new(MockKubectl)
mockWriter := new(MockWriter)
namespace := ""
_, err := mainLogic(mockKubectl, mockWriter, namespace, []string{"deployment"})
if err == nil {
t.Errorf("Expected error")
}
}
func TestFailingIfRevisionDoesNotExist(t *testing.T) {
mockKubectl := new(MockKubectl)
mockKubectl.On("getRolloutHistoryWithRevision", "deployment", "nginx", 1, "").Return("", errors.New("error"))
mockWriter := new(MockWriter)
namespace := ""
_, err := mainLogic(mockKubectl, mockWriter, namespace, []string{"deployment", "nginx", "1", "2"})
if err == nil {
t.Errorf("Expected error")
}
}