Address broken tests

This commit is contained in:
Denis Makogon
2017-05-30 08:50:53 -07:00
committed by James Jeffrey
parent 04008c71fd
commit 31b4ac4516
18 changed files with 49 additions and 46 deletions

View File

@@ -274,7 +274,7 @@ func Test(t *testing.T, ds models.Datastore) {
// unchanged
AppName: testRoute.AppName,
Path: testRoute.Path,
Image: "treeder/hello",
Image: "funcy/hello",
Type: "sync",
Format: "http",
// updated
@@ -317,7 +317,7 @@ func Test(t *testing.T, ds models.Datastore) {
// unchanged
AppName: testRoute.AppName,
Path: testRoute.Path,
Image: "treeder/hello",
Image: "funcy/hello",
Type: "sync",
Format: "http",
Timeout: 100,
@@ -482,7 +482,7 @@ var testApp = &models.App{
var testRoute = &models.Route{
AppName: testApp.Name,
Path: "/test",
Image: "treeder/hello",
Image: "funcy/hello",
Type: "sync",
Format: "http",
}

View File

@@ -27,7 +27,7 @@ func (f *taskDockerTest) EnvVars() map[string]string {
func (f *taskDockerTest) Labels() map[string]string { return nil }
func (f *taskDockerTest) Id() string { return f.id }
func (f *taskDockerTest) Group() string { return "" }
func (f *taskDockerTest) Image() string { return "treeder/hello" }
func (f *taskDockerTest) Image() string { return "funcy/hello" }
func (f *taskDockerTest) Timeout() time.Duration { return 30 * time.Second }
func (f *taskDockerTest) Logger() (stdout, stderr io.Writer) { return f.output, nil }
func (f *taskDockerTest) WriteStat(drivers.Stat) { /* TODO */ }

View File

@@ -94,14 +94,14 @@ func TestDecimate(t *testing.T) {
func TestParseImage(t *testing.T) {
cases := map[string][]string{
"treeder/hello": {"", "treeder/hello", "latest"},
"treeder/hello:v1": {"", "treeder/hello", "v1"},
"funcy/hello": {"", "funcy/hello", "latest"},
"funcy/hello:v1": {"", "funcy/hello", "v1"},
"my.registry/hello": {"my.registry", "hello", "latest"},
"my.registry/hello:v1": {"my.registry", "hello", "v1"},
"mongo": {"", "library/mongo", "latest"},
"mongo:v1": {"", "library/mongo", "v1"},
"quay.com/treeder/hello": {"quay.com", "treeder/hello", "latest"},
"quay.com:8080/treeder/hello:v2": {"quay.com:8080", "treeder/hello", "v2"},
"quay.com/funcy/hello": {"quay.com", "funcy/hello", "latest"},
"quay.com:8080/funcy/hello:v2": {"quay.com:8080", "funcy/hello", "v2"},
"localhost.localdomain:5000/samalba/hipache:latest": {"localhost.localdomain:5000", "samalba/hipache", "latest"},
}

View File

@@ -29,8 +29,8 @@ func TestRunnerHello(t *testing.T) {
expectedOut string
expectedErr string
}{
{&models.Route{Image: "treeder/hello"}, ``, "success", "Hello World!", ""},
{&models.Route{Image: "treeder/hello"}, `{"name": "test"}`, "success", "Hello test!", ""},
{&models.Route{Image: "funcy/hello"}, ``, "success", "Hello World!", ""},
{&models.Route{Image: "funcy/hello"}, `{"name": "test"}`, "success", "Hello test!", ""},
} {
var stdout, stderr bytes.Buffer
cfg := &task.Config{

View File

@@ -29,12 +29,12 @@ func TestRouteCreate(t *testing.T) {
{datastore.NewMock(), "/v1/apps/a/routes", `{ "path": "/myroute" }`, http.StatusBadRequest, models.ErrRoutesMissingNew},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { } }`, http.StatusBadRequest, models.ErrRoutesValidationMissingPath},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "path": "/myroute" } }`, http.StatusBadRequest, models.ErrRoutesValidationMissingImage},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "treeder/hello" } }`, http.StatusBadRequest, models.ErrRoutesValidationMissingPath},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "treeder/hello", "path": "myroute" } }`, http.StatusBadRequest, models.ErrRoutesValidationInvalidPath},
{datastore.NewMock(), "/v1/apps/$/routes", `{ "route": { "image": "treeder/hello", "path": "/myroute" } }`, http.StatusInternalServerError, models.ErrAppsValidationInvalidName},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "funcy/hello" } }`, http.StatusBadRequest, models.ErrRoutesValidationMissingPath},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "funcy/hello", "path": "myroute" } }`, http.StatusBadRequest, models.ErrRoutesValidationInvalidPath},
{datastore.NewMock(), "/v1/apps/$/routes", `{ "route": { "image": "funcy/hello", "path": "/myroute" } }`, http.StatusInternalServerError, models.ErrAppsValidationInvalidName},
// success
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "treeder/hello", "path": "/myroute" } }`, http.StatusOK, nil},
{datastore.NewMock(), "/v1/apps/a/routes", `{ "route": { "image": "funcy/hello", "path": "/myroute" } }`, http.StatusOK, nil},
} {
rnr, cancel := testRunner(t)
srv := testServer(test.mock, &mqs.Mock{}, rnr, tasks)
@@ -207,7 +207,7 @@ func TestRouteUpdate(t *testing.T) {
Path: "/myroute/do",
},
},
), "/v1/apps/a/routes/myroute/do", `{ "route": { "image": "treeder/hello" } }`, http.StatusOK, nil},
), "/v1/apps/a/routes/myroute/do", `{ "route": { "image": "funcy/hello" } }`, http.StatusOK, nil},
// Addresses #381
{datastore.NewMockInit(nil,

View File

@@ -45,9 +45,9 @@ func TestRouteRunnerAsyncExecution(t *testing.T) {
{Name: "myapp", Config: map[string]string{"app": "true"}},
},
[]*models.Route{
{Type: "async", Path: "/myroute", AppName: "myapp", Image: "treeder/hello", Config: map[string]string{"test": "true"}},
{Type: "async", Path: "/myroute", AppName: "myapp", Image: "funcy/hello", Config: map[string]string{"test": "true"}},
{Type: "async", Path: "/myerror", AppName: "myapp", Image: "funcy/error", Config: map[string]string{"test": "true"}},
{Type: "async", Path: "/myroute/:param", AppName: "myapp", Image: "treeder/hello", Config: map[string]string{"test": "true"}},
{Type: "async", Path: "/myroute/:param", AppName: "myapp", Image: "funcy/hello", Config: map[string]string{"test": "true"}},
},
)
mq := &mqs.Mock{}

View File

@@ -128,7 +128,7 @@ func TestRouteRunnerExecution(t *testing.T) {
{Name: "myapp", Config: models.Config{}},
},
[]*models.Route{
{Path: "/myroute", AppName: "myapp", Image: "treeder/hello", Headers: map[string][]string{"X-Function": {"Test"}}},
{Path: "/myroute", AppName: "myapp", Image: "funcy/hello", Headers: map[string][]string{"X-Function": {"Test"}}},
{Path: "/myerror", AppName: "myapp", Image: "funcy/error", Headers: map[string][]string{"X-Function": {"Test"}}},
},
), &mqs.Mock{}, rnr, tasks)

View File

@@ -120,7 +120,7 @@ func TestFullStack(t *testing.T) {
{"create my app", "POST", "/v1/apps", `{ "app": { "name": "myapp" } }`, http.StatusOK, 0},
{"list apps", "GET", "/v1/apps", ``, http.StatusOK, 0},
{"get app", "GET", "/v1/apps/myapp", ``, http.StatusOK, 0},
{"add myroute", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute", "path": "/myroute", "image": "treeder/hello" } }`, http.StatusOK, 1},
{"add myroute", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute", "path": "/myroute", "image": "funcy/hello" } }`, http.StatusOK, 1},
{"add myroute2", "POST", "/v1/apps/myapp/routes", `{ "route": { "name": "myroute2", "path": "/myroute2", "image": "funcy/error" } }`, http.StatusOK, 2},
{"get myroute", "GET", "/v1/apps/myapp/routes/myroute", ``, http.StatusOK, 2},
{"get myroute2", "GET", "/v1/apps/myapp/routes/myroute2", ``, http.StatusOK, 2},

View File

@@ -30,7 +30,7 @@ func TestSpecialHandlerSet(t *testing.T) {
// {Name: "test"},
// },
// Routes: []*models.Route{
// {Path: "/test", Image: "treeder/hello", AppName: "test"},
// {Path: "/test", Image: "funcy/hello", AppName: "test"},
// },
// },
// MQ: &mqs.Mock{},