作者:nicrege
项目:bos
func createdTmpDir(t *testing.T, fs boshsys.FileSystem) (dstDir string) {
dstDir = filepath.Join(os.TempDir(), "TestCompressor")
err := fs.MkdirAll(dstDir, os.ModePerm)
assert.NoError(t, err)
return
}
作者:ronakbank
项目:vagrant-bos
func NewConfigFromPath(path string, fs boshsys.FileSystem) (Config, error) {
var config Config
bytes, err := fs.ReadFile(path)
if err != nil {
return config, bosherr.WrapError(err, "Reading config %s", path)
}
config = DefaultWardenConfig
err = json.Unmarshal(bytes, &config)
if err != nil {
return config, bosherr.WrapError(err, "Unmarshalling config")
}
if config.VMProvisioner.AgentProvisioner.Configuration == nil {
config.VMProvisioner.AgentProvisioner.Configuration = DefaultWardenAgentConfiguration
}
err = config.validate()
if err != nil {
return config, bosherr.WrapError(err, "Validating config")
}
return config, nil
}
作者:ronakbank
项目:vagrant-bos
// NewManifestFromPath returns manifest read from the file system.
// Before returning manifest is syntactically validated.
func NewManifestFromPath(path string, fs boshsys.FileSystem) (Manifest, error) {
bytes, err := fs.ReadFile(path)
if err != nil {
return Manifest{}, bosherr.WrapError(err, "Reading manifest %s", path)
}
return NewManifestFromBytes(bytes)
}
作者:Bosh-for-Cp
项目:bosh-260
func LoadConfigFromPath(fs boshsys.FileSystem, path string) (Config, error) {
var config Config
if path == "" {
return config, nil
}
bytes, err := fs.ReadFile(path)
if err != nil {
return config, bosherr.WrapError(err, "Reading file")
}
err = json.Unmarshal(bytes, &config)
if err != nil {
return config, bosherr.WrapError(err, "Loading file")
}
return config, nil
}
作者:punalpate
项目:bos
package devicepathresolver
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
boshsys "bosh/system"
fakesys "bosh/system/fakes"
)
var _ = Describe("Path Resolver", func() {
var (
fs boshsys.FileSystem
resolver DevicePathResolver
)
BeforeEach(func() {
fs = fakesys.NewFakeFileSystem()
resolver = NewAwsDevicePathResolver(time.Second, fs)
})
Context("When a matching /dev/xvdX device is found", func() {
BeforeEach(func() {
fs.WriteFile("/dev/xvda", []byte{})
fs.WriteFile("/dev/vda", []byte{})
fs.WriteFile("/dev/sda", []byte{})
})
It("returns the match", func() {
作者:amulya
项目:bosh-cloudstack-cp
"os"
"path/filepath"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"
boshlog "bosh/logger"
. "bosh/platform/commands"
boshsys "bosh/system"
)
var _ = Describe("cpCopier", func() {
var (
fs boshsys.FileSystem
cmdRunner boshsys.CmdRunner
cpCopier Copier
)
BeforeEach(func() {
logger := boshlog.NewLogger(boshlog.LevelNone)
fs = boshsys.NewOsFileSystem(logger)
cmdRunner = boshsys.NewExecCmdRunner(logger)
cpCopier = NewCpCopier(cmdRunner, fs, logger)
})
Describe("FilteredCopyToTemp", func() {
copierFixtureSrcDir := func() string {
pwd, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())
return filepath.Join(pwd, "..", "..", "..", "..", "fixtures", "test_filtered_copy_to_temp")