From bb8f12ece98f9eb5993829d8502edbbc40921566 Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Fri, 28 Jul 2017 13:32:13 +0300 Subject: [PATCH] Fixing tests and CI file --- Makefile | 3 +++ api/runner/async_runner.go | 4 ++-- api/runner/async_runner_test.go | 4 ++-- circle.yml | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 45890400b..777ae347e 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ build: test: ./test.sh +fmt: + ./go-fmt.sh + test-datastore: cd api/datastore && go test -v ./... diff --git a/api/runner/async_runner.go b/api/runner/async_runner.go index 8dcde6c14..848a25228 100644 --- a/api/runner/async_runner.go +++ b/api/runner/async_runner.go @@ -27,7 +27,7 @@ func getTask(ctx context.Context, url string) (*models.Task, error) { span, _ := opentracing.StartSpanFromContext(ctx, "get_task") defer span.Finish() - req, _ := http.NewRequest("GET", url, nil) + req, _ := http.NewRequest(http.MethodGet, url, nil) resp, err := http.DefaultClient.Do(req.WithContext(ctx)) defer func() { io.Copy(ioutil.Discard, resp.Body) @@ -37,7 +37,7 @@ func getTask(ctx context.Context, url string) (*models.Task, error) { return nil, err } if resp.StatusCode != http.StatusOK { - return nil, errors.New(fmt.Sprintf("Unable to get task. Reason %v", resp.Status)) + return nil, errors.New(fmt.Sprintf("Unable to get task. Reason: %v", resp.Status)) } var task models.Task diff --git a/api/runner/async_runner_test.go b/api/runner/async_runner_test.go index fa57443e6..c0ad456ae 100644 --- a/api/runner/async_runner_test.go +++ b/api/runner/async_runner_test.go @@ -63,7 +63,7 @@ func getTestServer(mockTasks []*models.Task) *httptest.Server { c.JSON(http.StatusInternalServerError, err) return } - c.JSON(http.StatusAccepted, task) + c.JSON(http.StatusOK, task) } delHandler := func(c *gin.Context) { @@ -120,7 +120,7 @@ func TestGetTaskError(t *testing.T) { { "url": "/invalid", "task": getMockTask(), - "error": "json: cannot unmarshal number into Go value of type models.Task", // TODO WTF! + "error": "Unable to get task. Reason: 404 Not Found", }, } diff --git a/circle.yml b/circle.yml index 6eaf54796..22f2bf84e 100644 --- a/circle.yml +++ b/circle.yml @@ -27,6 +27,8 @@ dependencies: test: override: + - make fmt: + pwd: $GO_PROJECT - make test: pwd: $GO_PROJECT - make test-build-arm: