|
4 | 4 | "context" |
5 | 5 | "testing" |
6 | 6 |
|
| 7 | + "github.com/docker/cli/cli/config" |
| 8 | + |
7 | 9 | log "github.com/sirupsen/logrus" |
8 | 10 | assert "github.com/stretchr/testify/assert" |
9 | 11 | ) |
@@ -35,15 +37,25 @@ func TestCleanImage(t *testing.T) { |
35 | 37 | func TestGetImagePullOptions(t *testing.T) { |
36 | 38 | ctx := context.Background() |
37 | 39 |
|
| 40 | + config.SetDir("/non-existent/docker") |
| 41 | + |
38 | 42 | options, err := getImagePullOptions(ctx, NewDockerPullExecutorInput{}) |
39 | 43 | assert.Nil(t, err, "Failed to create ImagePullOptions") |
40 | | - assert.Equal(t, options.RegistryAuth, "", "RegistryAuth should be empty if no username or password is set") |
| 44 | + assert.Equal(t, "", options.RegistryAuth, "RegistryAuth should be empty if no username or password is set") |
41 | 45 |
|
42 | 46 | options, err = getImagePullOptions(ctx, NewDockerPullExecutorInput{ |
43 | 47 | Image: "", |
44 | 48 | Username: "username", |
45 | 49 | Password: "password", |
46 | 50 | }) |
47 | 51 | assert.Nil(t, err, "Failed to create ImagePullOptions") |
48 | | - assert.Equal(t, options.RegistryAuth, "eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZCJ9", "Username and Password should be provided") |
| 52 | + assert.Equal(t, "eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZCJ9", options.RegistryAuth, "Username and Password should be provided") |
| 53 | + |
| 54 | + config.SetDir("testdata/docker-pull-options") |
| 55 | + |
| 56 | + options, err = getImagePullOptions(ctx, NewDockerPullExecutorInput{ |
| 57 | + Image: "nektos/act", |
| 58 | + }) |
| 59 | + assert.Nil(t, err, "Failed to create ImagePullOptions") |
| 60 | + assert.Equal(t, "eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwicGFzc3dvcmQiOiJwYXNzd29yZFxuIiwic2VydmVyYWRkcmVzcyI6Imh0dHBzOi8vaW5kZXguZG9ja2VyLmlvL3YxLyJ9", options.RegistryAuth, "RegistryAuth should be taken from local docker config") |
49 | 61 | } |
0 commit comments