Skip to content

Commit

Permalink
Fix function name
Browse files Browse the repository at this point in the history
  • Loading branch information
ryosan-470 committed Jul 19, 2017
1 parent d4afbfe commit 6f34012
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ package ctftime

const (
BUFSIZE = 1024
TEST_FILE = "./test_data/event_1.json"
URL_PREFIX = "https://ctftime.org/api/v1" // API Endpoint
)
2 changes: 1 addition & 1 deletion event.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func GetAPIData() []Event {
if err != nil {
log.Fatal(err)
}
Decode(response, &events)
HttpResponseToStruct(response, &events)

return events
}
2 changes: 1 addition & 1 deletion event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestDecodeGetAPIData(t *testing.T) {
Body: ioutil.NopCloser(bytes.NewReader(body)),
}
var api_data []Event
Decode(dummy_resp, &api_data)
HttpResponseToStruct(dummy_resp, &api_data)

if len(api_data) != 3 {
t.Error("Invalid event length!")
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
)

func Decode(r *http.Response, v interface{}) {
func HttpResponseToStruct(r *http.Response, v interface{}) {
defer r.Body.Close()
body, err := ioutil.ReadAll(r.Body)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestDecodeJsonResponse(t *testing.T) {
buf, err := ioutil.ReadFile(TEST_FILE)
buf, err := ioutil.ReadFile("./test_data/event_1.json")
if err != nil {
log.Fatal(err)
}
Expand All @@ -27,5 +27,5 @@ func TestDecodeJsonResponse(t *testing.T) {
}

var events []interface{}
Decode(response, &events)
HttpResponseToStruct(response, &events)
}

0 comments on commit 6f34012

Please sign in to comment.