|
5 | 5 | "io/ioutil" |
6 | 6 | "os" |
7 | 7 | "testing" |
| 8 | + |
| 9 | + "github.com/stretchr/testify/assert" |
8 | 10 | ) |
9 | 11 |
|
10 | 12 | var ( |
@@ -86,16 +88,12 @@ func TestGetCurrentContainerID(t *testing.T) { |
86 | 88 | // Each time the HOSTNAME is set to a short form ID, GetCurrentContainerID() should match and return the corresponding full ID |
87 | 89 | for _, id := range ids { |
88 | 90 | 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") |
92 | 92 | } |
93 | 93 |
|
94 | 94 | // If the Hostname isn't a short form ID, we should match the first valid ID (64 character hex string) instead |
95 | 95 | 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") |
99 | 97 | } |
100 | 98 |
|
101 | 99 | func TestGetCurrentContainerIDMountInfo(t *testing.T) { |
@@ -128,7 +126,5 @@ func TestGetCurrentContainerIDMountInfo(t *testing.T) { |
128 | 126 | } |
129 | 127 |
|
130 | 128 | // 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") |
134 | 130 | } |
0 commit comments