Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: memory/testing_utils_test.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « memory/taskqueue_test.go ('k') | prod/context.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: memory/testing_utils_test.go
diff --git a/memory/testing_utils_test.go b/memory/testing_utils_test.go
deleted file mode 100644
index 24796a223956facc948a1c999625ac061ec036ee..0000000000000000000000000000000000000000
--- a/memory/testing_utils_test.go
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package memory
-
-import (
- "bytes"
- "fmt"
- "time"
-
- "github.com/luci/gae"
- "github.com/luci/gae/helper"
- "github.com/luci/luci-go/common/cmpbin"
-)
-
-type kv struct{ k, v []byte }
-
-func indx(kind string, orders ...string) *qIndex {
- ancestor := false
- if kind[len(kind)-1] == '!' {
- ancestor = true
- kind = kind[:len(kind)-1]
- }
- ret := &qIndex{kind, ancestor, nil}
- for _, o := range orders {
- dir := qASC
- if o[0] == '-' {
- dir = qDEC
- o = o[1:]
- }
- ret.sortby = append(ret.sortby, qSortBy{o, dir})
- }
- return ret
-}
-
-var (
- prop = gae.MkDSProperty
- propNI = gae.MkDSPropertyNI
-)
-
-func key(kind string, id interface{}, parent ...gae.DSKey) gae.DSKey {
- p := gae.DSKey(nil)
- if len(parent) > 0 {
- p = parent[0]
- }
- switch x := id.(type) {
- case string:
- return helper.NewDSKey(globalAppID, "ns", kind, x, 0, p)
- case int:
- return helper.NewDSKey(globalAppID, "ns", kind, "", int64(x), p)
- default:
- panic(fmt.Errorf("what the %T: %v", id, id))
- }
-}
-
-// cat is a convenience method for concatenating anything with an underlying
-// byte representation into a single []byte.
-func cat(bytethings ...interface{}) []byte {
- buf := &bytes.Buffer{}
- for _, thing := range bytethings {
- switch x := thing.(type) {
- case int64:
- cmpbin.WriteInt(buf, x)
- case int:
- cmpbin.WriteInt(buf, int64(x))
- case uint64:
- cmpbin.WriteUint(buf, x)
- case uint:
- cmpbin.WriteUint(buf, uint64(x))
- case float64:
- cmpbin.WriteFloat64(buf, x)
- case byte:
- buf.WriteByte(x)
- case gae.DSPropertyType:
- buf.WriteByte(byte(x))
- case string:
- cmpbin.WriteString(buf, x)
- case []byte:
- buf.Write(x)
- case time.Time:
- helper.WriteTime(buf, x)
- case gae.DSKey:
- helper.WriteDSKey(buf, helper.WithoutContext, x)
- case *qIndex:
- x.WriteBinary(buf)
- default:
- panic(fmt.Errorf("I don't know how to deal with %T: %#v", thing, thing))
- }
- }
- ret := buf.Bytes()
- if ret == nil {
- ret = []byte{}
- }
- return ret
-}
-
-func icat(bytethings ...interface{}) []byte {
- ret := cat(bytethings...)
- for i := range ret {
- ret[i] ^= 0xFF
- }
- return ret
-}
-
-func sat(bytethings ...interface{}) string {
- return string(cat(bytethings...))
-}
« no previous file with comments | « memory/taskqueue_test.go ('k') | prod/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698