mirror of https://github.com/docker/compose.git
Removed unit tests (using example context) that are in fact duplicates of e2e tests in test/e2e
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
2a8c24e4ff
commit
907ba0c03e
|
@ -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")
|
|
||||||
}
|
|
|
@ -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")
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"ID": "id",
|
|
||||||
"Status": "",
|
|
||||||
"Image": "nginx",
|
|
||||||
"HostConfig": {
|
|
||||||
"RestartPolicy": "none",
|
|
||||||
"CPUReservation": 0,
|
|
||||||
"CPULimit": 0,
|
|
||||||
"MemoryReservation": 0,
|
|
||||||
"MemoryLimit": 0,
|
|
||||||
"AutoRemove": false
|
|
||||||
},
|
|
||||||
"Platform": "Linux"
|
|
||||||
}
|
|
|
@ -1,2 +0,0 @@
|
||||||
id
|
|
||||||
1234
|
|
|
@ -1,3 +0,0 @@
|
||||||
CONTAINER ID IMAGE COMMAND STATUS PORTS
|
|
||||||
id nginx
|
|
||||||
1234 alpine
|
|
|
@ -20,13 +20,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"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.
|
// TestCLI is a helper struct for CLI tests.
|
||||||
|
@ -36,33 +29,6 @@ type TestCLI struct {
|
||||||
reader *os.File
|
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
|
// Context returns a configured context
|
||||||
func (c *TestCLI) Context() context.Context {
|
func (c *TestCLI) Context() context.Context {
|
||||||
return c.ctx
|
return c.ctx
|
||||||
|
|
Loading…
Reference in New Issue