2017-04-03 20:59:09 -04:00
|
|
|
// +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")
|
2018-08-14 03:51:22 -04:00
|
|
|
c.Assert(err, checker.IsNil) // ensure temp file is created
|
2017-04-03 20:59:09 -04:00
|
|
|
defer os.Remove(testFile.Name())
|
|
|
|
|
|
|
|
testData := "TESTINGDATA"
|
|
|
|
_, err = testFile.Write([]byte(testData))
|
2018-08-14 03:51:22 -04:00
|
|
|
c.Assert(err, checker.IsNil) // ensure temp file is written
|
2017-04-03 20:59:09 -04:00
|
|
|
|
|
|
|
testName := "test_config"
|
|
|
|
out, err := d.Cmd("config", "create", testName, testFile.Name())
|
2018-08-14 03:51:22 -04:00
|
|
|
c.Assert(err, checker.IsNil, check.Commentf("%s", out))
|
|
|
|
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
2017-04-03 20:59:09 -04:00
|
|
|
|
|
|
|
id := strings.TrimSpace(out)
|
|
|
|
config := d.GetConfig(c, id)
|
|
|
|
c.Assert(config.Spec.Name, checker.Equals, testName)
|
|
|
|
}
|