-
Notifications
You must be signed in to change notification settings - Fork 565
/
container_export_test.go
36 lines (33 loc) · 1.02 KB
/
container_export_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package docker
import (
"bytes"
"net/http"
"testing"
)
func TestExportContainer(t *testing.T) {
t.Parallel()
content := "exported container tar content"
out := stdoutMock{bytes.NewBufferString(content)}
client := newTestClient(&FakeRoundTripper{status: http.StatusOK})
opts := ExportContainerOptions{ID: "4fa6e0f0c678", OutputStream: out}
err := client.ExportContainer(opts)
if err != nil {
t.Errorf("ExportContainer: caugh error %#v while exporting container, expected nil", err.Error())
}
if out.String() != content {
t.Errorf("ExportContainer: wrong stdout. Want %#v. Got %#v.", content, out.String())
}
}
func TestExportContainerNoId(t *testing.T) {
t.Parallel()
client := Client{}
out := stdoutMock{bytes.NewBufferString("")}
err := client.ExportContainer(ExportContainerOptions{OutputStream: out})
e, ok := err.(*NoSuchContainer)
if !ok {
t.Errorf("ExportContainer: wrong error. Want NoSuchContainer. Got %#v.", e)
}
if e.ID != "" {
t.Errorf("ExportContainer: wrong ID. Want %q. Got %q", "", e.ID)
}
}