Esempio n. 1
0
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 <*****@*****.**>")); err != nil {
		t.Fatal(err)
	}
	if err := AssertThat(config.Description, Is("-")); err != nil {
		t.Fatal(err)
	}
}
Esempio n. 2
0
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)
	}
}
Esempio n. 3
0
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)
	}
}
Esempio n. 4
0
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)
	}
}
Esempio n. 5
0
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)
	}
}
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)
		}
	}
}
Esempio n. 7
0
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)
	}
}
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 <*****@*****.**>
Description: my test package
`)); err != nil {
		t.Fatal(err)
	}
}
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())
}
Esempio n. 10
0
func createDefaultConfig() *debian_config.Config {
	config := debian_config.DefaultConfig()
	config.Name = bamboo.PACKAGE_NAME
	config.Architecture = bamboo.ARCH
	return config
}
func createDefaultConfig() *debian_config.Config {
	config := debian_config.DefaultConfig()
	config.Name = jira_servicedesk.PACKAGE_NAME
	config.Architecture = jira_servicedesk.ARCH
	return config
}
Esempio n. 12
0
func createDefaultConfig() *debian_config.Config {
	config := debian_config.DefaultConfig()
	config.Name = "nexus"
	config.Architecture = "amd64"
	return config
}
Esempio n. 13
0
func New() *configBuilder {
	return NewWithConfig(debian_config.DefaultConfig())
}
Esempio n. 14
0
func createDefaultConfig() *debian_config.Config {
	config := debian_config.DefaultConfig()
	config.Name = "golang-latest"
	config.Architecture = "amd64"
	return config
}