Esempio n. 1
0
func TestPostProcessorMetadata_artifact(t *testing.T) {
	config := validDefaults()
	config["metadata"] = map[string]string{
		"foo": "bar",
	}

	var p PostProcessor
	if err := p.Configure(config); err != nil {
		t.Fatalf("err: %s", err)
	}

	artifact := new(packer.MockArtifact)
	artifact.StateValues = map[string]interface{}{
		ArtifactStateMetadata: map[interface{}]interface{}{
			"bar": "baz",
		},
	}

	metadata := p.metadata(artifact)
	expected := map[string]string{
		"foo": "bar",
		"bar": "baz",
	}
	if !reflect.DeepEqual(metadata, expected) {
		t.Fatalf("bad: %#v", metadata)
	}
}
func (s *MySuite) Test_BuilderId(c *C) {
	a := packer.MockArtifact{BuilderIdValue: "bla"}

	sut := PostProcessor{}
	_, _, err := sut.PostProcess(testUi(c), &a)
	c.Assert(err, NotNil)
	c.Assert(strings.Contains(err.Error(), "Can only import from Azure builder"), Equals, true)

	a.BuilderIdValue = azure.BuilderId
	_, _, err = sut.PostProcess(testUi(c), &a)
	c.Assert(err, NotNil)
	c.Assert(strings.Contains(err.Error(), "Can only import from Azure builder"), Equals, false)
}
Esempio n. 3
0
func TestPostProcessorType_artifact(t *testing.T) {
	var p PostProcessor
	if err := p.Configure(validDefaults()); err != nil {
		t.Fatalf("err: %s", err)
	}

	artifact := new(packer.MockArtifact)
	artifact.StateValues = map[string]interface{}{
		ArtifactStateType: "bar",
	}
	actual := p.artifactType(artifact)
	if actual != "bar" {
		t.Fatalf("bad: %#v", actual)
	}
}