Skip to content

Commit d8aa021

Browse files
Fix context test
1 parent 73bbe7b commit d8aa021

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

context.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ type Docker struct {
157157
func GetCurrentContainerID() string {
158158
file, err := os.Open("/proc/self/cgroup")
159159

160-
if os.IsNotExist(err) {
161-
return ""
162-
} else if err != nil {
163-
log.Printf("Fail to open /proc/self/cgroup: %s\n", err)
160+
if err != nil {
161+
if os.IsExist(err) {
162+
log.Printf("Fail to open /proc/self/cgroup: %s\n", err)
163+
}
164+
164165
return ""
165166
}
166167

context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func TestGetCurrentContainerID(t *testing.T) {
88
currentContainerID := GetCurrentContainerID()
99

10-
if len(currentContainerID) != 64 {
10+
if len(currentContainerID) != 0 && len(currentContainerID) != 64 {
1111
t.Fail()
1212
}
1313
}

0 commit comments

Comments
 (0)