forked from openshift/osde2e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e_test.go
More file actions
58 lines (45 loc) · 1.29 KB
/
e2e_test.go
File metadata and controls
58 lines (45 loc) · 1.29 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
package common
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
"github.com/openshift/osde2e/pkg/config"
"github.com/openshift/osde2e/pkg/events"
)
func TestNoHiveLogs(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "")
if err != nil {
t.Errorf("failed to create temporary directory: %v", err)
}
defer os.RemoveAll(tmpDir)
if resetEvents() != nil {
t.Errorf("list of events is not empty on start: %v", err)
}
config.Instance.ReportDir = tmpDir
checkBeforeMetricsGeneration()
if !reflect.DeepEqual(events.GetListOfEvents(), []string{string(events.NoHiveLogs)}) {
t.Errorf("the NoHiveLogs event was not detected")
}
// Make sure the events are clear again
if resetEvents() != nil {
t.Errorf("list of events is not empty during second hive log check: %v", err)
}
_, err = os.Create(filepath.Join(tmpDir, hiveLog))
if err != nil {
t.Errorf("error creating dummy hive log: %v", err)
}
checkBeforeMetricsGeneration()
if !reflect.DeepEqual(events.GetListOfEvents(), []string{}) {
t.Errorf("the NoHiveLogs event should not have been detected")
}
}
func resetEvents() error {
events.Instance.Events = map[string]bool{}
if !reflect.DeepEqual(events.GetListOfEvents(), []string{}) {
return fmt.Errorf("list of events is not empty on reset")
}
return nil
}