TestGetUserFromImageUser tests the logic of getting image uid or user name of image user.
(t *testing.T)
| 84 | |
| 85 | // TestGetUserFromImageUser tests the logic of getting image uid or user name of image user. |
| 86 | func TestGetUserFromImageUser(t *testing.T) { |
| 87 | newI64 := func(i int64) *int64 { return &i } |
| 88 | for c, test := range map[string]struct { |
| 89 | user string |
| 90 | uid *int64 |
| 91 | name string |
| 92 | }{ |
| 93 | "no gid": { |
| 94 | user: "0", |
| 95 | uid: newI64(0), |
| 96 | }, |
| 97 | "uid/gid": { |
| 98 | user: "0:1", |
| 99 | uid: newI64(0), |
| 100 | }, |
| 101 | "empty user": { |
| 102 | user: "", |
| 103 | }, |
| 104 | "multiple spearators": { |
| 105 | user: "1:2:3", |
| 106 | uid: newI64(1), |
| 107 | }, |
| 108 | "root username": { |
| 109 | user: "root:root", |
| 110 | name: "root", |
| 111 | }, |
| 112 | "username": { |
| 113 | user: "test:test", |
| 114 | name: "test", |
| 115 | }, |
| 116 | } { |
| 117 | t.Logf("TestCase - %q", c) |
| 118 | actualUID, actualName := getUserFromImageUser(test.user) |
| 119 | assert.Equal(t, test.uid, actualUID) |
| 120 | assert.Equal(t, test.name, actualName) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func TestParsingCreationConflictError(t *testing.T) { |
| 125 | // Expected error message from docker. |
nothing calls this directly
no test coverage detected
searching dependent graphs…