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

Side by Side Diff: service/datastore/index_test.go

Issue 1574353004: GitHub #8: Seed indexes from index.yml (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: path argument in FindAndParseIndexYAML, add a couple of tests Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « service/datastore/index.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // adapted from github.com/golang/appengine/datastore 5 // adapted from github.com/golang/appengine/datastore
6 6
7 package datastore 7 package datastore
8 8
9 import ( 9 import (
10 "fmt"
10 "strings" 11 "strings"
11 "testing" 12 "testing"
12 13
13 . "github.com/smartystreets/goconvey/convey" 14 . "github.com/smartystreets/goconvey/convey"
15 "gopkg.in/yaml.v2"
14 ) 16 )
15 17
16 var indexDefinitionTests = []struct { 18 var indexDefinitionTests = []struct {
17 id *IndexDefinition 19 id *IndexDefinition
18 builtin bool 20 builtin bool
19 compound bool 21 compound bool
20 str string 22 str string
21 yaml []string 23 yaml []string
22 }{ 24 }{
23 { 25 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 for _, tc := range indexDefinitionTests { 75 for _, tc := range indexDefinitionTests {
74 Convey(tc.str, func() { 76 Convey(tc.str, func() {
75 So(tc.id.String(), ShouldEqual, tc.str) 77 So(tc.id.String(), ShouldEqual, tc.str)
76 So(tc.id.Builtin(), ShouldEqual, tc.builtin) 78 So(tc.id.Builtin(), ShouldEqual, tc.builtin)
77 So(tc.id.Compound(), ShouldEqual, tc.compound) 79 So(tc.id.Compound(), ShouldEqual, tc.compound)
78 yaml, _ := tc.id.YAMLString() 80 yaml, _ := tc.id.YAMLString()
79 So(yaml, ShouldEqual, strings.Join(tc.yaml, "\n" )) 81 So(yaml, ShouldEqual, strings.Join(tc.yaml, "\n" ))
80 }) 82 })
81 } 83 }
82 }) 84 })
85
86 Convey("Test MarshalYAML/UnmarshalYAML", t, func() {
87 for _, tc := range indexDefinitionTests {
88 Convey(fmt.Sprintf("marshallable index definition `%s` i s marshalled and unmarshalled correctly", tc.str), func() {
89 if tc.yaml != nil {
90 // marshal
91 _, err := yaml.Marshal(tc.id)
92 So(err, ShouldBeNil)
93
94 // unmarshal
95 var ids []*IndexDefinition
96 yaml.Unmarshal([]byte(strings.Join(tc.ya ml, "\n")), &ids)
97 So(ids[0], ShouldResemble, tc.id)
98 }
99 })
100 }
101 })
83 } 102 }
OLDNEW
« no previous file with comments | « service/datastore/index.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698