-
Notifications
You must be signed in to change notification settings - Fork 13
/
identity_test.go
76 lines (64 loc) · 1.13 KB
/
identity_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package neco
import (
"os"
"testing"
)
func testMyLRN(t *testing.T) {
t.Parallel()
f, err := os.CreateTemp("", "")
if err != nil {
t.Fatal(err)
}
defer func() {
f.Close()
os.Remove(f.Name())
}()
_, err = f.WriteString("1\n")
if err != nil {
t.Fatal(err)
}
RackFile = f.Name()
lrn, err := MyLRN()
if err != nil {
t.Fatal(err)
}
if lrn != 1 {
t.Error("MyLRN should return 1, actual: ", lrn)
}
}
func testMyCluster(t *testing.T) {
t.Parallel()
f, err := os.CreateTemp("", "")
if err != nil {
t.Fatal(err)
}
defer func() {
f.Close()
os.Remove(f.Name())
}()
_, err = f.WriteString("my-cluster\n")
if err != nil {
t.Fatal(err)
}
ClusterFile = f.Name()
cluster, err := MyCluster()
if err != nil {
t.Fatal(err)
}
if cluster != "my-cluster" {
t.Error("MyCluster should return 'my-cluster', actual: ", cluster)
}
}
func testOSCodename(t *testing.T) {
t.Parallel()
codename, err := OSCodename()
if err != nil {
t.Fatal(err)
}
t.Log("os codename:", codename)
}
func TestIdentity(t *testing.T) {
t.Run("MyLRN", testMyLRN)
t.Run("MyCluster", testMyCluster)
t.Run("OSCodename", testOSCodename)
}