Unify testutil.Unmount on Windows and Unix
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
This commit is contained in:
		 Paul "TBBle" Hampson
					Paul "TBBle" Hampson
				
			
				
					committed by
					
						 Gabriel Adrian Samfira
						Gabriel Adrian Samfira
					
				
			
			
				
	
			
			
			 Gabriel Adrian Samfira
						Gabriel Adrian Samfira
					
				
			
						parent
						
							474a257b16
						
					
				
				
					commit
					84cc3e496b
				
			| @@ -23,6 +23,9 @@ import ( | ||||
| 	"path/filepath" | ||||
| 	"strconv" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| var rootEnabled bool | ||||
| @@ -79,3 +82,10 @@ func DumpDirOnFailure(t *testing.T, root string) { | ||||
| 		DumpDir(t, root) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Unmount unmounts a given mountPoint and sets t.Error if it fails | ||||
| func Unmount(t testing.TB, mountPoint string) { | ||||
| 	t.Log("unmount", mountPoint) | ||||
| 	err := mount.UnmountAll(mountPoint, umountflags) | ||||
| 	assert.NoError(t, err) | ||||
| } | ||||
|   | ||||
| @@ -23,17 +23,9 @@ import ( | ||||
| 	"os" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/containerd/containerd/mount" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| ) | ||||
|  | ||||
| // Unmount unmounts a given mountPoint and sets t.Error if it fails | ||||
| func Unmount(t testing.TB, mountPoint string) { | ||||
| 	t.Log("unmount", mountPoint) | ||||
| 	err := mount.UnmountAll(mountPoint, umountflags) | ||||
| 	assert.NoError(t, err) | ||||
| } | ||||
|  | ||||
| // RequiresRoot skips tests that require root, unless the test.root flag has | ||||
| // been set | ||||
| func RequiresRoot(t testing.TB) { | ||||
|   | ||||
| @@ -25,8 +25,3 @@ func RequiresRoot(t testing.TB) { | ||||
| // RequiresRootM is similar to RequiresRoot but intended to be called from *testing.M. | ||||
| func RequiresRootM() { | ||||
| } | ||||
|  | ||||
| // Unmount unmounts a given mountPoint and sets t.Error if it fails | ||||
| // Does nothing on Windows | ||||
| func Unmount(t *testing.T, mountPoint string) { | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| //go:build !linux && !windows | ||||
| //go:build !linux | ||||
| // +build !linux | ||||
|  | ||||
| /* | ||||
|    Copyright The containerd Authors. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user