| Index: server/logdog/storage/memory/memory_test.go
|
| diff --git a/server/logdog/storage/memory/memory_test.go b/server/logdog/storage/memory/memory_test.go
|
| index 1cb0bd1d5835e8e94e5f9eeda3e87baa460664d6..09761a4dc6f81b832bd57ce54dafa91c2c82e832 100644
|
| --- a/server/logdog/storage/memory/memory_test.go
|
| +++ b/server/logdog/storage/memory/memory_test.go
|
| @@ -11,6 +11,7 @@ import (
|
| "testing"
|
| "time"
|
|
|
| + "github.com/luci/luci-go/common/config"
|
| "github.com/luci/luci-go/common/logdog/types"
|
| "github.com/luci/luci-go/server/logdog/storage"
|
|
|
| @@ -43,6 +44,7 @@ func TestBigTable(t *testing.T) {
|
| st := Storage{}
|
| defer st.Close()
|
|
|
| + project := config.ProjectName("test-project")
|
| path := types.StreamPath("testing/+/foo/bar")
|
|
|
| Convey(`Can Put() log stream records {0..5, 7, 8, 10}.`, func() {
|
| @@ -50,8 +52,9 @@ func TestBigTable(t *testing.T) {
|
|
|
| putRange := func(start types.MessageIndex, count int) error {
|
| req := storage.PutRequest{
|
| - Path: path,
|
| - Index: start,
|
| + Project: project,
|
| + Path: path,
|
| + Index: start,
|
| }
|
| for i := 0; i < count; i++ {
|
| index := start + types.MessageIndex(i)
|
| @@ -81,12 +84,13 @@ func TestBigTable(t *testing.T) {
|
| }
|
|
|
| Convey(`Put()`, func() {
|
| + req := storage.PutRequest{
|
| + Project: project,
|
| + Path: path,
|
| + }
|
| +
|
| Convey(`Will return ErrExists when putting an existing entry.`, func() {
|
| - req := storage.PutRequest{
|
| - Path: path,
|
| - Index: 5,
|
| - Values: [][]byte{[]byte("ohai")},
|
| - }
|
| + req.Values = [][]byte{[]byte("ohai")}
|
|
|
| So(st.Put(req), ShouldEqual, storage.ErrExists)
|
| })
|
| @@ -94,29 +98,24 @@ func TestBigTable(t *testing.T) {
|
| Convey(`Will return an error if one is set.`, func() {
|
| st.SetErr(errors.New("test error"))
|
|
|
| - req := storage.PutRequest{
|
| - Path: path,
|
| - Index: 1337,
|
| - }
|
| + req.Index = 1337
|
| So(st.Put(req), ShouldErrLike, "test error")
|
| })
|
| })
|
|
|
| Convey(`Get()`, func() {
|
| - Convey(`Can retrieve all of the records correctly.`, func() {
|
| - req := storage.GetRequest{
|
| - Path: path,
|
| - }
|
| + req := storage.GetRequest{
|
| + Project: project,
|
| + Path: path,
|
| + }
|
|
|
| + Convey(`Can retrieve all of the records correctly.`, func() {
|
| So(st.Get(req, getAllCB), ShouldBeNil)
|
| So(getRecs, ShouldResemble, recs)
|
| })
|
|
|
| Convey(`Will adhere to GetRequest limit.`, func() {
|
| - req := storage.GetRequest{
|
| - Path: path,
|
| - Limit: 4,
|
| - }
|
| + req.Limit = 4
|
|
|
| So(st.Get(req, getAllCB), ShouldBeNil)
|
| So(getRecs, ShouldResemble, recs[:4])
|
| @@ -124,20 +123,13 @@ func TestBigTable(t *testing.T) {
|
|
|
| Convey(`Will adhere to hard limit.`, func() {
|
| st.MaxGetCount = 3
|
| - req := storage.GetRequest{
|
| - Path: path,
|
| - Limit: 4,
|
| - }
|
| + req.Limit = 4
|
|
|
| So(st.Get(req, getAllCB), ShouldBeNil)
|
| So(getRecs, ShouldResemble, recs[:3])
|
| })
|
|
|
| Convey(`Will stop iterating if callback returns false.`, func() {
|
| - req := storage.GetRequest{
|
| - Path: path,
|
| - }
|
| -
|
| count := 0
|
| err := st.Get(req, func(types.MessageIndex, []byte) bool {
|
| count++
|
| @@ -147,10 +139,14 @@ func TestBigTable(t *testing.T) {
|
| So(count, ShouldEqual, 1)
|
| })
|
|
|
| - Convey(`Will fail to retrieve records if the stream doesn't exist.`, func() {
|
| - req := storage.GetRequest{
|
| - Path: "testing/+/does/not/exist",
|
| - }
|
| + Convey(`Will fail to retrieve records if the project doesn't exist.`, func() {
|
| + req.Project = "project-does-not-exist"
|
| +
|
| + So(st.Get(req, getAllCB), ShouldEqual, storage.ErrDoesNotExist)
|
| + })
|
| +
|
| + Convey(`Will fail to retrieve records if the path doesn't exist.`, func() {
|
| + req.Path = "testing/+/does/not/exist"
|
|
|
| So(st.Get(req, getAllCB), ShouldEqual, storage.ErrDoesNotExist)
|
| })
|
| @@ -158,29 +154,31 @@ func TestBigTable(t *testing.T) {
|
| Convey(`Will return an error if one is set.`, func() {
|
| st.SetErr(errors.New("test error"))
|
|
|
| - req := storage.GetRequest{
|
| - Path: path,
|
| - }
|
| So(st.Get(req, nil), ShouldErrLike, "test error")
|
| })
|
| })
|
|
|
| Convey(`Tail()`, func() {
|
| Convey(`Can retrieve the tail record, 10.`, func() {
|
| - d, idx, err := st.Tail(path)
|
| + d, idx, err := st.Tail(project, path)
|
| So(err, ShouldBeNil)
|
| So(d, ShouldResemble, numRec(10).data)
|
| So(idx, ShouldEqual, 10)
|
| })
|
|
|
| - Convey(`Will fail to retrieve records if the stream doesn't exist.`, func() {
|
| - _, _, err := st.Tail("testing/+/does/not/exist")
|
| + Convey(`Will fail to retrieve records if the project doesn't exist.`, func() {
|
| + _, _, err := st.Tail("project-does-not-exist", path)
|
| + So(err, ShouldEqual, storage.ErrDoesNotExist)
|
| + })
|
| +
|
| + Convey(`Will fail to retrieve records if the path doesn't exist.`, func() {
|
| + _, _, err := st.Tail(project, "testing/+/does/not/exist")
|
| So(err, ShouldEqual, storage.ErrDoesNotExist)
|
| })
|
|
|
| Convey(`Will return an error if one is set.`, func() {
|
| st.SetErr(errors.New("test error"))
|
| - _, _, err := st.Tail("")
|
| + _, _, err := st.Tail("", "")
|
| So(err, ShouldErrLike, "test error")
|
| })
|
| })
|
|
|