mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
34 lines
914 B
Go
34 lines
914 B
Go
|
// +build !windows
|
||
|
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"strings"
|
||
|
|
||
|
"github.com/docker/docker/integration-cli/checker"
|
||
|
"github.com/go-check/check"
|
||
|
)
|
||
|
|
||
|
func (s *DockerSwarmSuite) TestConfigCreateWithFile(c *check.C) {
|
||
|
d := s.AddDaemon(c, true, true)
|
||
|
|
||
|
testFile, err := ioutil.TempFile("", "configCreateTest")
|
||
|
c.Assert(err, checker.IsNil, check.Commentf("failed to create temporary file"))
|
||
|
defer os.Remove(testFile.Name())
|
||
|
|
||
|
testData := "TESTINGDATA"
|
||
|
_, err = testFile.Write([]byte(testData))
|
||
|
c.Assert(err, checker.IsNil, check.Commentf("failed to write to temporary file"))
|
||
|
|
||
|
testName := "test_config"
|
||
|
out, err := d.Cmd("config", "create", testName, testFile.Name())
|
||
|
c.Assert(err, checker.IsNil)
|
||
|
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "", check.Commentf(out))
|
||
|
|
||
|
id := strings.TrimSpace(out)
|
||
|
config := d.GetConfig(c, id)
|
||
|
c.Assert(config.Spec.Name, checker.Equals, testName)
|
||
|
}
|