本文整理汇总了Golang中github.com/bborbe/debian_utils/config.DefaultConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang DefaultConfig函数的具体用法?Golang DefaultConfig怎么用?Golang DefaultConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DefaultConfig函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestDefaults
func TestDefaults(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Section, Is("base")); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Priority, Is("optional")); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Architecture, Is("all")); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Maintainer, Is("Benjamin Borbe <[email protected]>")); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Description, Is("-")); err != nil {
t.Fatal(err)
}
}
示例2: TestParseConfigFilesEmpty
func TestParseConfigFilesEmpty(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{"files":[]}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(len(config.Files), Is(0)); err != nil {
t.Fatal(err)
}
}
示例3: TestParseConfigVersion
func TestParseConfigVersion(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{"version":"1.2.3"}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Version, Is("1.2.3")); err != nil {
t.Fatal(err)
}
}
示例4: TestParseConfigName
func TestParseConfigName(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{"name":"helloworld"}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Name, Is("helloworld")); err != nil {
t.Fatal(err)
}
}
示例5: TestParseConfigArchitecture
func TestParseConfigArchitecture(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{"architecture":"amd64"}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Architecture, Is("amd64")); err != nil {
t.Fatal(err)
}
}
示例6: TestControlContentProvides
func TestControlContentProvides(t *testing.T) {
{
config := debian_config.DefaultConfig()
config.Provides = []string{"a"}
content := controlContent(*config)
if err := AssertThat(len(content), Not(Eq(0))); err != nil {
t.Fatal(err)
}
if err := AssertThat(string(content), Contains("\nProvides: a\n")); err != nil {
t.Fatal(err)
}
}
{
config := debian_config.DefaultConfig()
config.Provides = []string{"a", "b", "c"}
content := controlContent(*config)
if err := AssertThat(len(content), Not(Eq(0))); err != nil {
t.Fatal(err)
}
if err := AssertThat(string(content), Contains("\nProvides: a,b,c\n")); err != nil {
t.Fatal(err)
}
}
}
示例7: TestParseConfigFiles
func TestParseConfigFiles(t *testing.T) {
config := debian_config.DefaultConfig()
config, err := New().ParseContentToConfig(config, []byte(`{"files":[{"source":"/tmp/source.txt","target":"/tmp/target.txt"}]}`))
if err := AssertThat(err, NilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(config, NotNilValue()); err != nil {
t.Fatal(err)
}
if err := AssertThat(len(config.Files), Is(1)); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Files[0].Source, Is("/tmp/source.txt")); err != nil {
t.Fatal(err)
}
if err := AssertThat(config.Files[0].Target, Is("/tmp/target.txt")); err != nil {
t.Fatal(err)
}
}
示例8: TestControlContentDefault
func TestControlContentDefault(t *testing.T) {
config := debian_config.DefaultConfig()
config.Name = "testPackage"
config.Section = "utils"
config.Description = "my test package"
config.Version = "1.2.3"
content := controlContent(*config)
if err := AssertThat(len(content), Not(Eq(0))); err != nil {
t.Fatal(err)
}
if err := AssertThat(string(content), Is(`Package: testPackage
Version: 1.2.3
Section: utils
Priority: optional
Architecture: all
Maintainer: Benjamin Borbe <[email protected]>
Description: my test package
`)); err != nil {
t.Fatal(err)
}
}
示例9: do
func do(
config_parser debian_config_parser.ConfigParser,
configBuilderWithConfig ConfigBuilderWithConfig,
package_creator debian_package_creator.PackageCreator,
configpath string,
name string,
version string,
source string,
target string,
) error {
glog.Infof("config: %v name: %v version: %v source: %v target: %v", configpath, name, version, source, target)
var err error
config := debian_config.DefaultConfig()
if len(configpath) > 0 {
if config, err = config_parser.ParseFileToConfig(config, configpath); err != nil {
return err
}
}
config_builder := configBuilderWithConfig(config)
if len(source) > 0 && len(target) > 0 {
if err := config_builder.AddFile(source, target); err != nil {
return err
}
}
if len(name) > 0 {
if err := config_builder.Name(name); err != nil {
return err
}
}
if len(version) > 0 {
if err := config_builder.Version(version); err != nil {
return err
}
}
return package_creator.CreatePackage(config_builder.Build())
}
示例10: createDefaultConfig
func createDefaultConfig() *debian_config.Config {
config := debian_config.DefaultConfig()
config.Name = bamboo.PACKAGE_NAME
config.Architecture = bamboo.ARCH
return config
}
示例11: createDefaultConfig
func createDefaultConfig() *debian_config.Config {
config := debian_config.DefaultConfig()
config.Name = jira_servicedesk.PACKAGE_NAME
config.Architecture = jira_servicedesk.ARCH
return config
}
示例12: createDefaultConfig
func createDefaultConfig() *debian_config.Config {
config := debian_config.DefaultConfig()
config.Name = "nexus"
config.Architecture = "amd64"
return config
}
示例13: New
func New() *configBuilder {
return NewWithConfig(debian_config.DefaultConfig())
}