Skip to content

Commit 66b123c

Browse files
committed
tests: use testify/assert on context
1 parent 331416b commit 66b123c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

internal/dockergen/context_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"io/ioutil"
66
"os"
77
"testing"
8+
9+
"github.com/stretchr/testify/assert"
810
)
911

1012
var (
@@ -86,16 +88,12 @@ func TestGetCurrentContainerID(t *testing.T) {
8688
// Each time the HOSTNAME is set to a short form ID, GetCurrentContainerID() should match and return the corresponding full ID
8789
for _, id := range ids {
8890
os.Setenv("HOSTNAME", id[0:12])
89-
if got, exp := GetCurrentContainerID(filepaths...), id; got != exp {
90-
t.Fatalf("id mismatch with HOSTNAME %v: got %v, exp %v", id[0:12], got, exp)
91-
}
91+
assert.Equal(t, id, GetCurrentContainerID(filepaths...), "id mismatch with default HOSTNAME")
9292
}
9393

9494
// If the Hostname isn't a short form ID, we should match the first valid ID (64 character hex string) instead
9595
os.Setenv("HOSTNAME", "customhostname")
96-
if got, exp := GetCurrentContainerID(filepaths...), ids[0]; got != exp {
97-
t.Fatalf("id mismatch with custom HOSTNAME: got %v, exp %v", got, exp)
98-
}
96+
assert.Equal(t, ids[0], GetCurrentContainerID(filepaths...), "id mismatch with custom HOSTNAME")
9997
}
10098

10199
func TestGetCurrentContainerIDMountInfo(t *testing.T) {
@@ -128,7 +126,5 @@ func TestGetCurrentContainerIDMountInfo(t *testing.T) {
128126
}
129127

130128
// We should match the correct 64 characters long ID in mountinfo, not the first encountered
131-
if got, exp := GetCurrentContainerID(filepaths...), id; got != exp {
132-
t.Fatalf("id mismatch on mountinfo: got %v, exp %v", got, exp)
133-
}
129+
assert.Equal(t, id, GetCurrentContainerID(filepaths...), "id mismatch on mountinfo")
134130
}

0 commit comments

Comments
 (0)