test coverage for dockerfile package

This commit is contained in:
Brad Rydzewski 2014-03-13 17:07:33 -07:00
parent 62ec8634f6
commit 1a153b8e80

View file

@ -0,0 +1,63 @@
package dockerfile
import (
"testing"
)
func TestWrite(t *testing.T) {
var f = New("ubuntu")
var got, want = f.String(), "FROM ubuntu\n"
if got != want {
t.Errorf("Exepected New() returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteAdd("src", "target")
got, want = f.String(), "ADD src target\n"
if got != want {
t.Errorf("Exepected WriteAdd returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteFrom("ubuntu")
got, want = f.String(), "FROM ubuntu\n"
if got != want {
t.Errorf("Exepected WriteFrom returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteRun("whoami")
got, want = f.String(), "RUN whoami\n"
if got != want {
t.Errorf("Exepected WriteRun returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteUser("root")
got, want = f.String(), "USER root\n"
if got != want {
t.Errorf("Exepected WriteUser returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteEnv("FOO", "BAR")
got, want = f.String(), "ENV FOO BAR\n"
if got != want {
t.Errorf("Exepected WriteEnv returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteWorkdir("/home/ubuntu")
got, want = f.String(), "WORKDIR /home/ubuntu\n"
if got != want {
t.Errorf("Exepected WriteWorkdir returned %s, got %s", want, got)
}
f = &Dockerfile{}
f.WriteEntrypoint("/root")
got, want = f.String(), "ENTRYPOINT /root\n"
if got != want {
t.Errorf("Exepected WriteEntrypoint returned %s, got %s", want, got)
}
}