|
15 | 15 | package cli
|
16 | 16 |
|
17 | 17 | import (
|
| 18 | + "os" |
18 | 19 | "os/exec"
|
19 | 20 |
|
20 | 21 | . "github.com/onsi/ginkgo/v2"
|
@@ -108,4 +109,57 @@ var _ = Describe("home context", func() {
|
108 | 109 | Expect(contexts.Current).To(Equal(defaultContext))
|
109 | 110 | })
|
110 | 111 | })
|
| 112 | + |
| 113 | + Describe("add a podman context", Ordered, func() { |
| 114 | + testContext := "envd_home_test" |
| 115 | + testBuilder := types.BuilderTypePodman |
| 116 | + testBuilderAddress := "envd_buildkitd" |
| 117 | + testRunner := types.RunnerTypePodman |
| 118 | + c := types.Context{ |
| 119 | + Name: testContext, |
| 120 | + Builder: testBuilder, |
| 121 | + BuilderAddress: testBuilderAddress, |
| 122 | + Runner: testRunner, |
| 123 | + } |
| 124 | + originalEnv := os.Getenv("DOCKER_HOST") |
| 125 | + BeforeAll(func() { |
| 126 | + os.Setenv("DOCKER_HOST", "unix://"+os.Getenv("XDG_RUNTIME_DIR")+"/podman/podman.sock") |
| 127 | + err := home.GetManager().ContextCreate(c, true) |
| 128 | + Expect(err).NotTo(HaveOccurred()) |
| 129 | + }) |
| 130 | + |
| 131 | + It("should find a new context", func() { |
| 132 | + contexts, err := home.GetManager().ContextList() |
| 133 | + Expect(err).NotTo(HaveOccurred()) |
| 134 | + Expect(contexts.Current).To(Equal(testContext)) |
| 135 | + }) |
| 136 | + |
| 137 | + Describe("connect buildkit through podman-container", Ordered, func() { |
| 138 | + buildContext := "testdata/build-test" |
| 139 | + |
| 140 | + It("should be able to build image with podman context", func() { |
| 141 | + args := []string{"envd.test", "--debug", "build", "--path", buildContext} |
| 142 | + envdApp := app.New() |
| 143 | + e2e.ResetEnvdApp() |
| 144 | + err := envdApp.Run(args) |
| 145 | + Expect(err).NotTo(HaveOccurred()) |
| 146 | + }) |
| 147 | + }) |
| 148 | + |
| 149 | + It("fail to delete the current context", func() { |
| 150 | + err := home.GetManager().ContextRemove(testContext) |
| 151 | + Expect(err).To(HaveOccurred()) |
| 152 | + }) |
| 153 | + |
| 154 | + AfterAll(func() { |
| 155 | + os.Setenv("DOCKER_HOST", originalEnv) |
| 156 | + err := home.GetManager().ContextUse(defaultContext) |
| 157 | + Expect(err).NotTo(HaveOccurred()) |
| 158 | + err = home.GetManager().ContextRemove(testContext) |
| 159 | + Expect(err).NotTo(HaveOccurred()) |
| 160 | + contexts, err := home.GetManager().ContextList() |
| 161 | + Expect(err).NotTo(HaveOccurred()) |
| 162 | + Expect(contexts.Current).To(Equal(defaultContext)) |
| 163 | + }) |
| 164 | + }) |
111 | 165 | })
|
0 commit comments