surrealpatch/sql/rdwr_test.go
Tobie Morgan Hitchcock a569ad78d6 Improve statement read/write status detection
Only store read-write statement status in the database for statements which can be either read or write. For those statements which are always write statements (Live, Kill, Create, Update, Delete, Relate, Insert, Upsert, Define, Remove….), then hardcode this on the statement itself.
2017-11-24 12:56:53 +00:00

215 lines
5.2 KiB
Go

// Code generated by https://github.com/abcum/tmpl
// Source file: auth.gen.go.tmpl
// DO NOT EDIT!
// Copyright © 2016 Abcum Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package sql
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestRdwr(t *testing.T) {
Convey("InfoStatement should rdwr correctly", t, func() {
s := &InfoStatement{}
w := s.Writeable()
So(w, ShouldEqual, false)
})
Convey("IfStatement should rdwr correctly", t, func() {
s := &IfStatement{RW: true}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("LetStatement should rdwr correctly", t, func() {
s := &LetStatement{RW: true}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("ReturnStatement should rdwr correctly", t, func() {
s := &ReturnStatement{RW: true}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("LiveStatement should rdwr correctly", t, func() {
s := &LiveStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("KillStatement should rdwr correctly", t, func() {
s := &KillStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("SelectStatement should rdwr correctly", t, func() {
s := &SelectStatement{RW: true}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("CreateStatement should rdwr correctly", t, func() {
s := &CreateStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("UpdateStatement should rdwr correctly", t, func() {
s := &UpdateStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DeleteStatement should rdwr correctly", t, func() {
s := &DeleteStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RelateStatement should rdwr correctly", t, func() {
s := &RelateStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("InsertStatement should rdwr correctly", t, func() {
s := &InsertStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("UpsertStatement should rdwr correctly", t, func() {
s := &UpsertStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineNamespaceStatement should rdwr correctly", t, func() {
s := &DefineNamespaceStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveNamespaceStatement should rdwr correctly", t, func() {
s := &RemoveNamespaceStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineDatabaseStatement should rdwr correctly", t, func() {
s := &DefineDatabaseStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveDatabaseStatement should rdwr correctly", t, func() {
s := &RemoveDatabaseStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineLoginStatement should rdwr correctly", t, func() {
s := &DefineLoginStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveLoginStatement should rdwr correctly", t, func() {
s := &RemoveLoginStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineTokenStatement should rdwr correctly", t, func() {
s := &DefineTokenStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveTokenStatement should rdwr correctly", t, func() {
s := &RemoveTokenStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineScopeStatement should rdwr correctly", t, func() {
s := &DefineScopeStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveScopeStatement should rdwr correctly", t, func() {
s := &RemoveScopeStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineTableStatement should rdwr correctly", t, func() {
s := &DefineTableStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveTableStatement should rdwr correctly", t, func() {
s := &RemoveTableStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineEventStatement should rdwr correctly", t, func() {
s := &DefineEventStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveEventStatement should rdwr correctly", t, func() {
s := &RemoveEventStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineFieldStatement should rdwr correctly", t, func() {
s := &DefineFieldStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveFieldStatement should rdwr correctly", t, func() {
s := &RemoveFieldStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("DefineIndexStatement should rdwr correctly", t, func() {
s := &DefineIndexStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
Convey("RemoveIndexStatement should rdwr correctly", t, func() {
s := &RemoveIndexStatement{}
w := s.Writeable()
So(w, ShouldEqual, true)
})
}