mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #36429 from mnussbaum/cleanup_container_unit_test_temp_dir
Clean up a temp dir created in container unit test
This commit is contained in:
commit
7c7dfce37f
1 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,7 @@ package container // import "github.com/docker/docker/container"
|
|||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
@ -74,6 +75,7 @@ func TestContainerSecretReferenceDestTarget(t *testing.T) {
|
|||
func TestContainerLogPathSetForJSONFileLogger(t *testing.T) {
|
||||
containerRoot, err := ioutil.TempDir("", "TestContainerLogPathSetForJSONFileLogger")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(containerRoot)
|
||||
|
||||
c := &Container{
|
||||
Config: &container.Config{},
|
||||
|
@ -86,8 +88,9 @@ func TestContainerLogPathSetForJSONFileLogger(t *testing.T) {
|
|||
Root: containerRoot,
|
||||
}
|
||||
|
||||
_, err = c.StartLogger()
|
||||
logger, err := c.StartLogger()
|
||||
require.NoError(t, err)
|
||||
defer logger.Close()
|
||||
|
||||
expectedLogPath, err := filepath.Abs(filepath.Join(containerRoot, fmt.Sprintf("%s-json.log", c.ID)))
|
||||
require.NoError(t, err)
|
||||
|
@ -97,6 +100,7 @@ func TestContainerLogPathSetForJSONFileLogger(t *testing.T) {
|
|||
func TestContainerLogPathSetForRingLogger(t *testing.T) {
|
||||
containerRoot, err := ioutil.TempDir("", "TestContainerLogPathSetForRingLogger")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(containerRoot)
|
||||
|
||||
c := &Container{
|
||||
Config: &container.Config{},
|
||||
|
@ -112,8 +116,9 @@ func TestContainerLogPathSetForRingLogger(t *testing.T) {
|
|||
Root: containerRoot,
|
||||
}
|
||||
|
||||
_, err = c.StartLogger()
|
||||
logger, err := c.StartLogger()
|
||||
require.NoError(t, err)
|
||||
defer logger.Close()
|
||||
|
||||
expectedLogPath, err := filepath.Abs(filepath.Join(containerRoot, fmt.Sprintf("%s-json.log", c.ID)))
|
||||
require.NoError(t, err)
|
||||
|
|
Loading…
Add table
Reference in a new issue