Skip to content

Commit

Permalink
use t.Error when not t.Errorf is necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriciojs committed Jan 20, 2021
1 parent 8dd7354 commit 8d319fa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions api/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ func TestNewDeploy(t *testing.T) {
d := NewDeploy(tarball)

if _, ok := d.env.(*environment.DefaultEnvStorage); !ok {
t.Errorf("unexpected default environment.EnvStorage")
t.Error("unexpected default environment.EnvStorage")
}

if _, ok := d.Endpoint.(*DefaultEndpoint); !ok {
t.Errorf("unexpected default Endpoint")
t.Error("unexpected default Endpoint")
}

if tarball != d.tarballPath {
t.Errorf("failed setting tarballPath")
t.Error("failed setting tarballPath")
}

var id = "id"
d.id = id

if id != d.GetID() {
t.Errorf("failed setting id")
t.Error("failed setting id")
}

var url = "url"
d.Status = &StatusResponse{Status: "success", URL: url}

if !d.IsSuccessful() {
t.Errorf("failed asserting success")
t.Error("failed asserting success")
}

if url != d.GetURL() {
t.Errorf("failed getting URL")
t.Error("failed getting URL")
}

// still in need of testing
Expand Down
28 changes: 14 additions & 14 deletions api/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,66 +22,66 @@ func TestNewDefaultEndpoint(t *testing.T) {
e := newDefaultEndpoint(method)

if e.method != method {
t.Errorf("unexpected method")
t.Error("unexpected method")
}

if _, ok := e.env.(*environment.DefaultEnvStorage); !ok {
t.Errorf("unexpected environment storage")
t.Error("unexpected environment storage")
}

var path string = "path"
e.SetPath(path)

if e.path != path {
t.Errorf("failed to SetPath")
t.Error("failed to SetPath")
}

var contentType string = "type"
e.SetContentType(contentType)

if e.contentType != contentType {
t.Errorf("failed to SetContentType")
t.Error("failed to SetContentType")
}

if e.rawBody != nil {
t.Errorf("unexpected default rawBody")
t.Error("unexpected default rawBody")
}

e.SetRawBody(new(fakeIOReader))

if _, ok := e.rawBody.(*fakeIOReader); !ok {
t.Errorf("failed setting rawBody")
t.Error("failed setting rawBody")
}

if e.body != nil {
t.Errorf("unexpected non-null default body")
t.Error("unexpected non-null default body")
}

e.Body().Set("foo", "bar")
e.Body().Set("foo2", "bar2")

if e.body == nil {
t.Errorf("body must not be null after access")
t.Error("body must not be null after access")
}

if e.StatusCode() != e.statusCode || e.statusCode != 0 {
t.Errorf("unexpected default statusCode")
t.Error("unexpected default statusCode")
}

e.Query().Add("foo", "qbar")

if e.query.Get("foo") != "qbar" {
t.Errorf("failed to write query")
t.Error("failed to write query")
}

if e.response != nil {
t.Errorf("unexpected default response receiver")
t.Error("unexpected default response receiver")
}

e.SetResponseReceiver("receiver")

if resp, ok := e.response.(string); !ok || resp != "receiver" {
t.Errorf("failed SetResponseReceiver")
t.Error("failed SetResponseReceiver")
}
}

Expand Down Expand Up @@ -116,10 +116,10 @@ func TestDoRequest(t *testing.T) {
t.Errorf("unexpected error returned; %v", err)
}
if request.Header.Get("Accept") != "application/json" {
t.Errorf("failed setting Accept header")
t.Error("failed setting Accept header")
}

if !strings.Contains(request.Header.Get("Authorization"), "fake token") {
t.Errorf("failed setting Authorization header")
t.Error("failed setting Authorization header")
}
}

0 comments on commit 8d319fa

Please sign in to comment.