-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from linkernetworks/hwchiu/add-testing
Add more testing for src/net package Former-commit-id: a538a72367908d4ccd65075c51150895b2671175 [formerly a538a72367908d4ccd65075c51150895b2671175 [formerly a4b499e]] Former-commit-id: 97a29d99102caa6f167169365c04a42459b4a035 Former-commit-id: d273571
- Loading branch information
Showing
3 changed files
with
145 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package http | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"net/http" | ||
|
||
"github.com/linkernetworks/vortex/src/web" | ||
) | ||
|
||
func TestCompositeServiceHandler(t *testing.T) { | ||
data := 0 | ||
var handler = func(*web.NativeContext) { | ||
data += 1 | ||
} | ||
|
||
req, err := http.NewRequest("POST", "http://here.com/v1/signin", nil) | ||
assert.NoError(t, err) | ||
|
||
routeHandler := CompositeServiceHandler(nil, handler) | ||
assert.Equal(t, 0, data) | ||
routeHandler(nil, req) | ||
assert.Equal(t, 1, data) | ||
} | ||
|
||
func TestRESTfulServiceHandler(t *testing.T) { | ||
data := 0 | ||
var handler = func(*web.Context) { | ||
data += 1 | ||
} | ||
|
||
routeHandler := RESTfulServiceHandler(nil, handler) | ||
assert.Equal(t, 0, data) | ||
routeHandler(nil, nil) | ||
assert.Equal(t, 1, data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters