-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: Ide526ab99ee362f52359c80e31fa3541ad4ae849
- Loading branch information
Alexander Andryashin
committed
Jul 27, 2016
1 parent
052eb0d
commit 4866c89
Showing
2 changed files
with
30 additions
and
0 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,18 @@ | ||
package httpresp | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type Code struct { | ||
C int | ||
} | ||
|
||
func (m Code) Match(i interface{}) bool { | ||
return i.(*http.Response).StatusCode == m.C | ||
} | ||
|
||
func (m Code) String() string { | ||
return fmt.Sprintf("response code %v", m.C) | ||
} |
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,12 @@ | ||
package httpresp | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
. "github.com/aandryashin/matchers" | ||
) | ||
|
||
func TestTypeOf(t *testing.T) { | ||
AssertThat(t, &http.Response{StatusCode: 200}, Code{http.StatusOK}) | ||
AssertThat(t, Expect{&http.Response{StatusCode: 500}, Code{http.StatusOK}}, Fails{}) | ||
} |