func TestCmdExtractor(t *testing.T) { api := httpmock.NewServeReplay(t).Add(httpmock.PathHandler(t, "GET /images/remind101:acme-inc/json", 200, `{ "Config": { "Cmd": ["/go/bin/app","server"] } }`, )) c, s := newTestDockerClient(t, api) defer s.Close() e := cmdExtractor{ client: c, } got, err := e.Extract(Image{ ID: "acme-inc", Repo: "remind101", }) if err != nil { t.Fatal(err) } want := CommandMap{ ProcessType("web"): Command("/go/bin/app server"), } if !reflect.DeepEqual(got, want) { t.Errorf("Extract() => %q; want %q", got, want) } }
func TestProcfileFallbackExtractor(t *testing.T) { api := httpmock.NewServeReplay(t).Add(httpmock.PathHandler(t, "POST /containers/create", 200, `{ "ID": "abc" }`, )).Add(httpmock.PathHandler(t, "GET /containers/abc/json", 200, `{}`, )).Add(httpmock.PathHandler(t, "POST /containers/abc/copy", 404, ``, )).Add(httpmock.PathHandler(t, "DELETE /containers/abc", 200, `{}`, )).Add(httpmock.PathHandler(t, "GET /images/remind101:acme-inc/json", 200, `{ "Config": { "Cmd": ["/go/bin/app","server"] } }`, )) c, s := newTestDockerClient(t, api) defer s.Close() e := newProcfileFallbackExtractor(c) got, err := e.Extract(Image{ ID: "acme-inc", Repo: "remind101", }) if err != nil { t.Fatal(err) } want := CommandMap{ ProcessType("web"): Command("/go/bin/app server"), } if !reflect.DeepEqual(got, want) { t.Errorf("Extract() => %q; want %q", got, want) } }
func TestProcfileExtractor(t *testing.T) { api := httpmock.NewServeReplay(t).Add(httpmock.PathHandler(t, "POST /containers/create", 200, `{ "ID": "abc" }`, )).Add(httpmock.PathHandler(t, "GET /containers/abc/json", 200, `{}`, )).Add(httpmock.PathHandler(t, "POST /containers/abc/copy", 200, tarProcfile(t), )).Add(httpmock.PathHandler(t, "DELETE /containers/abc", 200, `{}`, )) c, s := newTestDockerClient(t, api) defer s.Close() e := procfileExtractor{ client: c, } got, err := e.Extract(Image{ ID: "acme-inc", Repo: "remind101", }) if err != nil { t.Fatal(err) } want := CommandMap{ ProcessType("web"): Command("rails server"), } if !reflect.DeepEqual(got, want) { t.Errorf("Extract() => %q; want %q", got, want) } }