Created
December 1, 2012 17:16
-
-
Save mjohnson9/4183298 to your computer and use it in GitHub Desktop.
This file contains 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 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