Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 197029b

Browse files
Simplify tests using directly golden.Assert and golden.Bytes
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent 2411bdc commit 197029b

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

e2e/commands_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package e2e
33
import (
44
"fmt"
55
"io/ioutil"
6+
"os"
67
"path/filepath"
78
"regexp"
89
"runtime"
@@ -81,10 +82,10 @@ func testRenderApp(appPath string, env ...string) func(*testing.T) {
8182
func TestRenderFormatters(t *testing.T) {
8283
appPath := filepath.Join("testdata", "simple", "simple.dockerapp")
8384
result := icmd.RunCommand(dockerApp, "render", "--formatter", "json", appPath).Assert(t, icmd.Success)
84-
assert.Assert(t, golden.String(result.Stdout(), "expected-json-render.golden"))
85+
golden.Assert(t, result.Stdout(), "expected-json-render.golden")
8586

8687
result = icmd.RunCommand(dockerApp, "render", "--formatter", "yaml", appPath).Assert(t, icmd.Success)
87-
assert.Assert(t, golden.String(result.Stdout(), "expected-yaml-render.golden"))
88+
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
8889
}
8990

9091
func TestInit(t *testing.T) {
@@ -155,7 +156,7 @@ maintainers:
155156

156157
appData, err := ioutil.ReadFile(tmpDir.Join("tac.dockerapp"))
157158
assert.NilError(t, err)
158-
assert.Assert(t, golden.Bytes(appData, "init-singlefile.dockerapp"))
159+
golden.Assert(t, string(appData), "init-singlefile.dockerapp")
159160
// Check various commands work on single-file app package
160161
cmd.Command = []string{dockerApp, "inspect", "tac"}
161162
icmd.RunCmd(cmd).Assert(t, icmd.Success)
@@ -207,15 +208,15 @@ func TestSplitMerge(t *testing.T) {
207208
// test that inspect works on single-file
208209
cmd.Command = []string{dockerApp, "inspect", "remerged"}
209210
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
210-
assert.Assert(t, golden.String(result.Combined(), "envvariables-inspect.golden"))
211+
golden.Assert(t, result.Combined(), "envvariables-inspect.golden")
211212

212213
// split it
213214
cmd.Command = []string{dockerApp, "split", "remerged", "-o", "split.dockerapp"}
214215
icmd.RunCmd(cmd).Assert(t, icmd.Success)
215216

216217
cmd.Command = []string{dockerApp, "inspect", "remerged"}
217218
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
218-
assert.Assert(t, golden.String(result.Combined(), "envvariables-inspect.golden"))
219+
golden.Assert(t, result.Combined(), "envvariables-inspect.golden")
219220

220221
// test inplace
221222
cmd.Command = []string{dockerApp, "merge", "split"}
@@ -228,7 +229,7 @@ func TestSplitMerge(t *testing.T) {
228229
func TestURL(t *testing.T) {
229230
url := "https://raw.githubusercontent.com/docker/app/v0.4.1/examples/hello-world/hello-world.dockerapp"
230231
result := icmd.RunCommand(dockerApp, "inspect", url).Assert(t, icmd.Success)
231-
assert.Assert(t, golden.String(result.Combined(), "helloworld-inspect.golden"))
232+
golden.Assert(t, result.Combined(), "helloworld-inspect.golden")
232233
}
233234

234235
func TestWithRegistry(t *testing.T) {
@@ -315,8 +316,7 @@ func TestDeployDockerApp(t *testing.T) {
315316
// The workaround is to create a context with an empty host.
316317
// This host will default to the unix socket inside the
317318
// invocation image
318-
host := ""
319-
cmd.Command = []string{dockerCli, "context", "create", "swarm-target-context", "--docker", fmt.Sprintf("host=%s", host), "--default-stack-orchestrator", "swarm"}
319+
cmd.Command = []string{dockerCli, "context", "create", "swarm-target-context", "--docker", "host=", "--default-stack-orchestrator", "swarm"}
320320
icmd.RunCmd(cmd).Assert(t, icmd.Success)
321321

322322
// Initialize the swarm

internal/inspect/inspect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ text: hello`),
112112
assert.NilError(t, err)
113113
err = Inspect(outBuffer, app, testcase.args, nil)
114114
assert.NilError(t, err)
115-
assert.Assert(t, golden.String(outBuffer.String(), fmt.Sprintf("inspect-%s.golden", testcase.name)))
115+
golden.Assert(t, outBuffer.String(), fmt.Sprintf("inspect-%s.golden", testcase.name))
116116
})
117117
}
118118
}

0 commit comments

Comments
 (0)