| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package hierarchy | 5 package hierarchy |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "testing" | 9 "testing" |
| 10 | 10 |
| 11 ds "github.com/luci/gae/service/datastore" | 11 ds "github.com/luci/gae/service/datastore" |
| 12 "github.com/luci/gae/service/info" | 12 "github.com/luci/gae/service/info" |
| 13 "github.com/luci/luci-go/logdog/appengine/coordinator" | 13 "github.com/luci/luci-go/logdog/appengine/coordinator" |
| 14 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest
" | 14 ct "github.com/luci/luci-go/logdog/appengine/coordinator/coordinatorTest
" |
| 15 "github.com/luci/luci-go/logdog/common/types" | 15 "github.com/luci/luci-go/logdog/common/types" |
| 16 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 16 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 17 | 17 |
| 18 . "github.com/luci/luci-go/common/testing/assertions" | 18 . "github.com/luci/luci-go/common/testing/assertions" |
| 19 . "github.com/smartystreets/goconvey/convey" | 19 . "github.com/smartystreets/goconvey/convey" |
| 20 ) | 20 ) |
| 21 | 21 |
| 22 func TestHierarchy(t *testing.T) { | 22 func TestHierarchy(t *testing.T) { |
| 23 t.Parallel() | 23 t.Parallel() |
| 24 | 24 |
| 25 » Convey(`With a testing configuration`, t, func() { | 25 » FocusConvey(`With a testing configuration`, t, func() { |
| 26 c, env := ct.Install() | 26 c, env := ct.Install() |
| 27 | 27 |
| 28 var r Request | 28 var r Request |
| 29 get := func() *List { | 29 get := func() *List { |
| 30 l, err := Get(c, r) | 30 l, err := Get(c, r) |
| 31 if err != nil { | 31 if err != nil { |
| 32 panic(err) | 32 panic(err) |
| 33 } | 33 } |
| 34 return l | 34 return l |
| 35 } | 35 } |
| 36 | 36 |
| 37 var lv listValidator | 37 var lv listValidator |
| 38 | 38 |
| 39 » » Convey(`When requesting Project-level list`, func() { | 39 » » FocusConvey(`When requesting Project-level list`, func() { |
| 40 r.Project = "" | 40 r.Project = "" |
| 41 | 41 |
| 42 » » » Convey(`An anonymous user will see all public-access pro
jects.`, func() { | 42 » » » FocusConvey(`An anonymous user will see all public-acces
s projects.`, func() { |
| 43 So(get(), lv.shouldHaveComponents, "proj-bar", "
proj-foo") | 43 So(get(), lv.shouldHaveComponents, "proj-bar", "
proj-foo") |
| 44 }) | 44 }) |
| 45 | 45 |
| 46 Convey(`An authenticated user will see all projects.`, f
unc() { | 46 Convey(`An authenticated user will see all projects.`, f
unc() { |
| 47 env.LogIn() | 47 env.LogIn() |
| 48 env.JoinGroup("auth") | 48 env.JoinGroup("auth") |
| 49 | 49 |
| 50 allProjects := []interface{}{"proj-bar", "proj-e
xclusive", "proj-foo"} | 50 allProjects := []interface{}{"proj-bar", "proj-e
xclusive", "proj-foo"} |
| 51 | 51 |
| 52 Convey(`Will see all projects.`, func() { | 52 Convey(`Will see all projects.`, func() { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 func norm(c []*ListComponent) []string { | 304 func norm(c []*ListComponent) []string { |
| 305 result := make([]string, len(c)) | 305 result := make([]string, len(c)) |
| 306 for i, e := range c { | 306 for i, e := range c { |
| 307 result[i] = e.Name | 307 result[i] = e.Name |
| 308 if e.Stream { | 308 if e.Stream { |
| 309 result[i] += "$" | 309 result[i] += "$" |
| 310 } | 310 } |
| 311 } | 311 } |
| 312 return result | 312 return result |
| 313 } | 313 } |
| OLD | NEW |