Last active
March 29, 2017 06:29
-
-
Save LillyWu/078d6554f4fad4e9d3addd3334765618 to your computer and use it in GitHub Desktop.
go
This file contains hidden or 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
package main | |
import ( | |
"testing" | |
"net/http/httptest" | |
"fmt" | |
"net/http" | |
) | |
func TestIt(t *testing.T){ | |
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
w.Header().Set("Content-Type", "application/json") | |
fmt.Fprintln(w, `{"fake twitter json string": "test"}`) | |
})) | |
defer ts.Close() | |
twitterUrl = ts.URL | |
c := make(chan *twitterResult) | |
go retrieveTweets(c) | |
tweet := <-c | |
t.Logf("tweet", tweet) | |
/* | |
if tweet != expected1 { | |
t.Fail() | |
} | |
tweet = <-c | |
if tweet != expected2 { | |
t.Fail() | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment