Home | History | Annotate | Download | only in aetest
      1 /*
      2 Package aetest provides an API for running dev_appserver for use in tests.
      3 
      4 An example test file:
      5 
      6 	package foo_test
      7 
      8 	import (
      9 		"testing"
     10 
     11 		"google.golang.org/appengine/memcache"
     12 		"google.golang.org/appengine/aetest"
     13 	)
     14 
     15 	func TestFoo(t *testing.T) {
     16 		ctx, done, err := aetest.NewContext()
     17 		if err != nil {
     18 			t.Fatal(err)
     19 		}
     20 		defer done()
     21 
     22 		it := &memcache.Item{
     23 			Key:   "some-key",
     24 			Value: []byte("some-value"),
     25 		}
     26 		err = memcache.Set(ctx, it)
     27 		if err != nil {
     28 			t.Fatalf("Set err: %v", err)
     29 		}
     30 		it, err = memcache.Get(ctx, "some-key")
     31 		if err != nil {
     32 			t.Fatalf("Get err: %v; want no error", err)
     33 		}
     34 		if g, w := string(it.Value), "some-value" ; g != w {
     35 			t.Errorf("retrieved Item.Value = %q, want %q", g, w)
     36 		}
     37 	}
     38 
     39 The environment variable APPENGINE_DEV_APPSERVER specifies the location of the
     40 dev_appserver.py executable to use. If unset, the system PATH is consulted.
     41 */
     42 package aetest
     43