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
// This file is part of https://github.com/mvmaasakkers/gohttptestmongodb/ | |
package main | |
import ( | |
"encoding/json" | |
"net/http" | |
"net/http/httptest" | |
"net/url" | |
"testing" | |
) |
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
// This file is part of https://github.com/mvmaasakkers/gohttptestmongodb/ | |
// Pages fixtures are intentionally setup as map[string]Page so I can easily select them from within the tests | |
var pages = map[string]Page{ | |
"ding": Page{Slug: "ding", Name: "Ding!", Content: "<i>HTML Awesomeness</i>"}, | |
"dong-ding": Page{Slug: "dong-ding", Name: "Dong! Ding!", Content: "<b>HTML Awesomeness</b>"}, | |
} | |
// insertFixtures just inserts all pages (and other types) I've defined above. | |
func insertFixtures() { | |
for _, page := range pages { |
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
// This file is part of https://github.com/mvmaasakkers/gohttptestmongodb/ | |
// Server holds the dbtest DBServer | |
var Server dbtest.DBServer | |
// TestMain wraps all tests with the needed initialized mock DB and fixtures | |
func TestMain(m *testing.M) { | |
// The tempdir is created so MongoDB has a location to store its files. | |
// Contents are wiped once the server stops | |
tempDir, _ := ioutil.TempDir("", "testing") | |
Server.SetPath(tempDir) |
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
# Usage: goget.sh [package] | |
# Example: goget.sh bitbucket.org/username/repo | |
# This script relies on keys being set correctly and $GOPATH being available | |
mkdir -p $GOPATH/src/$1 | |
git clone git://$1 $GOPATH/src/$1 | |
go get $1 |
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
// This is an example program that iterates over all | |
// items in a mongodb collection in a memory safe way | |
package main | |
import ( | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"fmt" | |
) |
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
<?php | |
function getPostfieldsFromInput() { | |
$ct = $_SERVER['CONTENT_TYPE']; | |
$position = stripos($ct, "multipart/form-data;"); | |
$input = file_get_contents("php://input"); | |
$postVars = array(); | |
if($position !== false) { | |
$exp = explode("boundary=", $ct); |
NewerOlder