Cleanup after migration

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
Daniel Nephin 2018-01-18 16:49:34 -05:00
parent ef48a0268e
commit 37aa41b164
5 changed files with 13 additions and 19 deletions

View File

@ -44,7 +44,7 @@ func TestNewFIFOSetInDir(t *testing.T) {
assert.Check(t, is.Equal("theid-stdin", filepath.Base(fifos.Stdin))) assert.Check(t, is.Equal("theid-stdin", filepath.Base(fifos.Stdin)))
assert.Check(t, is.Equal("theid-stdout", filepath.Base(fifos.Stdout))) assert.Check(t, is.Equal("theid-stdout", filepath.Base(fifos.Stdout)))
assert.Check(t, is.Equal("theid-stderr", filepath.Base(fifos.Stderr))) assert.Check(t, is.Equal("theid-stderr", filepath.Base(fifos.Stderr)))
assert.Check(t, is.Equal(true, fifos.Terminal)) assert.Check(t, fifos.Terminal)
files, err := ioutil.ReadDir(root) files, err := ioutil.ReadDir(root)
assert.NilError(t, err) assert.NilError(t, err)
@ -89,11 +89,11 @@ func TestNewAttach(t *testing.T) {
io.Wait() io.Wait()
io.Cancel() io.Cancel()
assert.Check(t, is.NilError(io.Close())) assert.NilError(t, io.Close())
assert.Check(t, is.Equal(expectedStdout, stdout.String())) assert.Check(t, is.EqualMultiLine(expectedStdout, stdout.String()))
assert.Check(t, is.Equal(expectedStderr, stderr.String())) assert.Check(t, is.EqualMultiLine(expectedStderr, stderr.String()))
assert.Check(t, is.Equal(expectedStdin, string(actualStdin))) assert.Check(t, is.EqualMultiLine(expectedStdin, string(actualStdin)))
} }
type producers struct { type producers struct {

View File

@ -3,6 +3,7 @@ package content
import ( import (
"bytes" "bytes"
"context" "context"
_ "crypto/sha256" // required by go-digest
"io" "io"
"strings" "strings"
"testing" "testing"

View File

@ -5,15 +5,14 @@ import (
"testing" "testing"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
) )
func TestLoggerContext(t *testing.T) { func TestLoggerContext(t *testing.T) {
ctx := context.Background() ctx := context.Background()
assert.Check(t, is.DeepEqual(GetLogger(ctx), L)) // should be same as L variable assert.Equal(t, GetLogger(ctx), L) // should be same as L variable
assert.Check(t, is.DeepEqual(G(ctx), GetLogger(ctx))) // these should be the same. assert.Equal(t, G(ctx), GetLogger(ctx)) // these should be the same.
ctx = WithLogger(ctx, G(ctx).WithField("test", "one")) ctx = WithLogger(ctx, G(ctx).WithField("test", "one"))
assert.Check(t, is.DeepEqual(GetLogger(ctx).Data["test"], "one")) assert.Equal(t, GetLogger(ctx).Data["test"], "one")
assert.Check(t, is.DeepEqual(G(ctx), GetLogger(ctx))) // these should be the same. assert.Equal(t, G(ctx), GetLogger(ctx)) // these should be the same.
} }

View File

@ -422,7 +422,6 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
} }
_, err = snapshotter.View(ctx, newLayer, snapA, opt) _, err = snapshotter.View(ctx, newLayer, snapA, opt)
//must be err != nil
assert.Check(t, err != nil) assert.Check(t, err != nil)
// Two Prepare with same key // Two Prepare with same key
@ -437,7 +436,6 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
} }
_, err = snapshotter.Prepare(ctx, prepLayer, snapA, opt) _, err = snapshotter.Prepare(ctx, prepLayer, snapA, opt)
//must be err != nil
assert.Check(t, err != nil) assert.Check(t, err != nil)
// Two View with same key // Two View with same key
@ -452,7 +450,6 @@ func checkSnapshotterPrepareView(ctx context.Context, t *testing.T, snapshotter
} }
_, err = snapshotter.View(ctx, viewLayer, snapA, opt) _, err = snapshotter.View(ctx, viewLayer, snapA, opt)
//must be err != nil
assert.Check(t, err != nil) assert.Check(t, err != nil)
} }

View File

@ -9,15 +9,13 @@ import (
"github.com/containerd/containerd/mount" "github.com/containerd/containerd/mount"
"github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
) )
// Unmount unmounts a given mountPoint and sets t.Error if it fails // Unmount unmounts a given mountPoint and sets t.Error if it fails
func Unmount(t *testing.T, mountPoint string) { func Unmount(t *testing.T, mountPoint string) {
t.Log("unmount", mountPoint) t.Log("unmount", mountPoint)
if err := mount.UnmountAll(mountPoint, umountflags); err != nil { err := mount.UnmountAll(mountPoint, umountflags)
t.Error("Could not umount", mountPoint, err) assert.NilError(t, err)
}
} }
// RequiresRoot skips tests that require root, unless the test.root flag has // RequiresRoot skips tests that require root, unless the test.root flag has
@ -25,9 +23,8 @@ func Unmount(t *testing.T, mountPoint string) {
func RequiresRoot(t testing.TB) { func RequiresRoot(t testing.TB) {
if !rootEnabled { if !rootEnabled {
t.Skip("skipping test that requires root") t.Skip("skipping test that requires root")
return
} }
assert.Check(t, is.Equal(0, os.Getuid()), "This test must be run as root.") assert.Equal(t, 0, os.Getuid(), "This test must be run as root.")
} }
// RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M. // RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M.