Skip to content

Instantly share code, notes, and snippets.

@mjohnson9
Created December 1, 2012 17:16
Show Gist options
  • Save mjohnson9/4183298 to your computer and use it in GitHub Desktop.
Save mjohnson9/4183298 to your computer and use it in GitHub Desktop.
package app
import (
"bytes"
"net/http"
"appengine"
"appengine/datastore"
)
type testStruct struct {
Test string
}
func init() {
req, err := http.NewRequest("GET", "/", new(bytes.Buffer)) // Construct a fake request
if err != nil {
panic(err) // We're just testing, so panic on errors
return
}
c := appengine.NewContext(req) // Make a Context from that fake request
key := datastore.NewKey(c, "test", "", 1, nil) // Attempt to make a key
toPut := &testStruct{ // Construct a silly test structure to store
Test: "asdf",
}
_, err = datastore.Put(c, key, toPut) // Attempt to store the silly test structure at the silly test key
if err != nil {
panic(err) // We're still testing, same applies
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment