From 358b0078c94de3c40c620bd534aba43a96c8b82b Mon Sep 17 00:00:00 2001 From: Matthew McKeen Date: Mon, 13 Jan 2014 13:21:34 -0800 Subject: [PATCH] docker-import + docker-push: Add some beginning tests. #774 --- .../docker-import/post-processor.go | 2 -- .../docker-import/post-processor_test.go | 31 +++++++++++++++++++ .../docker-push/post-processor_test.go | 31 +++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 post-processor/docker-import/post-processor_test.go create mode 100644 post-processor/docker-push/post-processor_test.go diff --git a/post-processor/docker-import/post-processor.go b/post-processor/docker-import/post-processor.go index a51e6ba6a..e0162a9c4 100644 --- a/post-processor/docker-import/post-processor.go +++ b/post-processor/docker-import/post-processor.go @@ -67,8 +67,6 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac id := artifact.Id() ui.Say("Importing image: " + id) - // TODO Set artifact ID so that docker-push can use it - if p.config.Tag == "" { cmd := exec.Command("docker", diff --git a/post-processor/docker-import/post-processor_test.go b/post-processor/docker-import/post-processor_test.go new file mode 100644 index 000000000..43ac0b4ef --- /dev/null +++ b/post-processor/docker-import/post-processor_test.go @@ -0,0 +1,31 @@ +package dockerimport + +import ( + "bytes" + "github.com/mitchellh/packer/packer" + "testing" +) + +func testConfig() map[string]interface{} { + return map[string]interface{}{} +} + +func testPP(t *testing.T) *PostProcessor { + var p PostProcessor + if err := p.Configure(testConfig()); err != nil { + t.Fatalf("err: %s", err) + } + + return &p +} + +func testUi() *packer.BasicUi { + return &packer.BasicUi{ + Reader: new(bytes.Buffer), + Writer: new(bytes.Buffer), + } +} + +func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { + var _ packer.PostProcessor = new(PostProcessor) +} diff --git a/post-processor/docker-push/post-processor_test.go b/post-processor/docker-push/post-processor_test.go new file mode 100644 index 000000000..7631da79d --- /dev/null +++ b/post-processor/docker-push/post-processor_test.go @@ -0,0 +1,31 @@ +package dockerpush + +import ( + "bytes" + "github.com/mitchellh/packer/packer" + "testing" +) + +func testConfig() map[string]interface{} { + return map[string]interface{}{} +} + +func testPP(t *testing.T) *PostProcessor { + var p PostProcessor + if err := p.Configure(testConfig()); err != nil { + t.Fatalf("err: %s", err) + } + + return &p +} + +func testUi() *packer.BasicUi { + return &packer.BasicUi{ + Reader: new(bytes.Buffer), + Writer: new(bytes.Buffer), + } +} + +func TestPostProcessor_ImplementsPostProcessor(t *testing.T) { + var _ packer.PostProcessor = new(PostProcessor) +}