diff --git a/cli/cmd/inspect_test.go b/cli/cmd/inspect_test.go deleted file mode 100644 index af75d4dfc..000000000 --- a/cli/cmd/inspect_test.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright 2020 Docker Compose CLI authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package cmd - -import ( - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/golden" - - _ "github.com/docker/compose-cli/example" - "github.com/docker/compose-cli/tests/framework" -) - -func TestInspectId(t *testing.T) { - c := framework.NewTestCLI(t) - err := runInspect(c.Context(), "id") - assert.NilError(t, err) - golden.Assert(t, c.GetStdOut(), "inspect-out-id.golden") -} diff --git a/cli/cmd/ps_test.go b/cli/cmd/ps_test.go deleted file mode 100644 index 7dc72d57c..000000000 --- a/cli/cmd/ps_test.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright 2020 Docker Compose CLI authors - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package cmd - -import ( - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/golden" - - _ "github.com/docker/compose-cli/example" - "github.com/docker/compose-cli/tests/framework" -) - -func TestPs(t *testing.T) { - c := framework.NewTestCLI(t) - opts := psOpts{ - quiet: false, - } - - err := runPs(c.Context(), opts) - assert.NilError(t, err) - - golden.Assert(t, c.GetStdOut(), "ps-out.golden") -} - -func TestPsQuiet(t *testing.T) { - c := framework.NewTestCLI(t) - opts := psOpts{ - quiet: true, - } - - err := runPs(c.Context(), opts) - assert.NilError(t, err) - - golden.Assert(t, c.GetStdOut(), "ps-out-quiet.golden") -} diff --git a/cli/cmd/testdata/inspect-out-id.golden b/cli/cmd/testdata/inspect-out-id.golden deleted file mode 100644 index 1200c98e4..000000000 --- a/cli/cmd/testdata/inspect-out-id.golden +++ /dev/null @@ -1,14 +0,0 @@ -{ - "ID": "id", - "Status": "", - "Image": "nginx", - "HostConfig": { - "RestartPolicy": "none", - "CPUReservation": 0, - "CPULimit": 0, - "MemoryReservation": 0, - "MemoryLimit": 0, - "AutoRemove": false - }, - "Platform": "Linux" -} diff --git a/cli/cmd/testdata/ps-out-quiet.golden b/cli/cmd/testdata/ps-out-quiet.golden deleted file mode 100644 index ceeb39db2..000000000 --- a/cli/cmd/testdata/ps-out-quiet.golden +++ /dev/null @@ -1,2 +0,0 @@ -id -1234 diff --git a/cli/cmd/testdata/ps-out.golden b/cli/cmd/testdata/ps-out.golden deleted file mode 100644 index ee7ef979c..000000000 --- a/cli/cmd/testdata/ps-out.golden +++ /dev/null @@ -1,3 +0,0 @@ -CONTAINER ID IMAGE COMMAND STATUS PORTS -id nginx -1234 alpine diff --git a/tests/framework/unit.go b/tests/framework/unit.go index 2e6cff58f..6f37d63d7 100644 --- a/tests/framework/unit.go +++ b/tests/framework/unit.go @@ -20,13 +20,6 @@ import ( "context" "io/ioutil" "os" - "testing" - - "gotest.tools/v3/assert" - "gotest.tools/v3/assert/cmp" - - apicontext "github.com/docker/compose-cli/api/context" - "github.com/docker/compose-cli/api/context/store" ) // TestCLI is a helper struct for CLI tests. @@ -36,33 +29,6 @@ type TestCLI struct { reader *os.File } -// NewTestCLI returns a CLI testing helper. -func NewTestCLI(t *testing.T) *TestCLI { - dir, err := ioutil.TempDir("", "store") - assert.Check(t, cmp.Nil(err)) - - originalStdout := os.Stdout - - t.Cleanup(func() { - os.Stdout = originalStdout - _ = os.RemoveAll(dir) - }) - - s, err := store.New(dir) - assert.Check(t, cmp.Nil(err)) - err = s.Create("example", "example", "", store.ContextMetadata{}) - assert.Check(t, cmp.Nil(err)) - - ctx := context.Background() - ctx = store.WithContextStore(ctx, s) - ctx = apicontext.WithCurrentContext(ctx, "example") - - r, w, err := os.Pipe() - os.Stdout = w - assert.Check(t, cmp.Nil(err)) - return &TestCLI{ctx, w, r} -} - // Context returns a configured context func (c *TestCLI) Context() context.Context { return c.ctx