go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/gae/docs/present/lightning/native_test.go (about) 1 // Copyright 2016 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 //go:build native_appengine 16 // +build native_appengine 17 18 package demo 19 20 import "testing" 21 import "google.golang.org/appengine/aetest" 22 import . "github.com/smartystreets/goconvey/convey" 23 24 // START OMIT 25 26 import "google.golang.org/appengine/datastore" // HL 27 28 func TestNative(t *testing.T) { 29 type Model struct{ A, B int } // HL 30 31 Convey("Put/Get", t, func() { 32 ctx, shtap, err := aetest.NewContext() 33 So(err, ShouldBeNil) 34 defer shtap() 35 36 keys := []*datastore.Key{ 37 datastore.NewKey(ctx, "Model", "one thing", 0, nil), // HL 38 datastore.NewKey(ctx, "Model", "or another", 0, nil), // HL 39 } 40 _, err = datastore.PutMulti(ctx, keys, []*Model{{10, 20}, {20, 30}}) // HL 41 So(err, ShouldBeNil) 42 43 ms := make([]*Model, 2) 44 So(datastore.GetMulti(ctx, keys, ms), ShouldBeNil) // HL 45 So(ms, ShouldResemble, []*Model{{10, 20}, {20, 30}}) 46 }) 47 } 48 49 // END OMIT