Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Create newserver_test.go - #7

Open
ehsan-fmb wants to merge 2 commits into
aoacademy:ehsan-fmbfrom
ehsan-fmb:patch-5
Open

Create newserver_test.go#7
ehsan-fmb wants to merge 2 commits into
aoacademy:ehsan-fmbfrom
ehsan-fmb:patch-5

Conversation

@ehsan-fmb

Copy link
Copy Markdown

and this is test file.

@ehsan-fmb

Copy link
Copy Markdown
Author

and other request is for give access to platform for send data to main server of iot project.

@1995parham 1995parham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check these commits and let me know 😄

Comment thread newserver_test.go
func TestPosting(t *testing.T){
e := echo.New()
e.POST("/posting",JsonHandler)
var jsonStr = []byte(`{"lat":"20ms","lng":"english"}`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have two separate tests for valid and invalid data that return different status codes.

Comment thread newserver_test.go
rr := httptest.NewRecorder()
e.ServeHTTP(rr, req)
status := rr.Code
if status != http.StatusOK {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use tesify library for assertion in tests. Use assertion makes your test automatic.

@1995parham
1995parham changed the base branch from master to ehsan-fmb May 18, 2019 04:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants