Skip to content

Instantly share code, notes, and snippets.

@LillyWu
Last active March 29, 2017 06:29
Show Gist options
  • Save LillyWu/078d6554f4fad4e9d3addd3334765618 to your computer and use it in GitHub Desktop.
Save LillyWu/078d6554f4fad4e9d3addd3334765618 to your computer and use it in GitHub Desktop.
go
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