Skip to content

Commit

Permalink
Merge pull request #31 from ali-ince/1.7-improvements
Browse files Browse the repository at this point in the history
Couple of improvements
  • Loading branch information
ali-ince authored Oct 23, 2018
2 parents e290fb3 + 05391c9 commit dcd86b4
Show file tree
Hide file tree
Showing 17 changed files with 948 additions and 70 deletions.
40 changes: 20 additions & 20 deletions neo4j/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
* 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
* 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.
* 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 neo4j

import (
"github.com/golang/mock/gomock"
"github.com/neo4j/neo4j-go-driver/neo4j/utils/mocks"
"github.com/neo4j/neo4j-go-driver/neo4j/utils/test"
. "github.com/onsi/ginkgo"
"github.com/onsi/gomega"
)

var _ = Describe("Logging", func() {
Expand All @@ -41,7 +42,7 @@ var _ = Describe("Logging", func() {
Context("errorf", func() {
When("Error level is not enabled", func() {
It("should not invoke Errorf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().ErrorEnabled().Times(1).Return(false)
logging.EXPECT().Errorf(gomock.Any(), gomock.Any()).Times(0)
Expand All @@ -52,11 +53,10 @@ var _ = Describe("Logging", func() {

When("Error level is enabled", func() {
It("should invoke Errorf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().ErrorEnabled().Times(1).Return(true)
// TODO: Add some custom matcher to match message itself?
logging.EXPECT().Errorf(gomock.Any(), "str1", 1).Times(1)
logging.EXPECT().Errorf(test.WrapMatcher(gomega.ContainSubstring("some error")), "str1", 1).Times(1)

errorf(logging, "some error", "str1", 1)
})
Expand All @@ -66,7 +66,7 @@ var _ = Describe("Logging", func() {
Context("warningf", func() {
When("Warning level is not enabled", func() {
It("should not invoke Warningf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().WarningEnabled().Times(1).Return(false)
logging.EXPECT().Warningf(gomock.Any(), gomock.Any()).Times(0)
Expand All @@ -77,10 +77,10 @@ var _ = Describe("Logging", func() {

When("Warning level is enabled", func() {
It("should invoke Warningf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().WarningEnabled().Times(1).Return(true)
logging.EXPECT().Warningf(gomock.Any(), "str1", 1).Times(1)
logging.EXPECT().Warningf(test.WrapMatcher(gomega.ContainSubstring("some warning")), "str1", 1).Times(1)

warningf(logging, "some warning", "str1", 1)
})
Expand All @@ -90,7 +90,7 @@ var _ = Describe("Logging", func() {
Context("infof", func() {
When("Info level is not enabled", func() {
It("should not invoke Infof on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().InfoEnabled().Times(1).Return(false)
logging.EXPECT().Infof(gomock.Any(), gomock.Any()).Times(0)
Expand All @@ -101,10 +101,10 @@ var _ = Describe("Logging", func() {

When("Info level is enabled", func() {
It("should invoke Infof on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().InfoEnabled().Times(1).Return(true)
logging.EXPECT().Infof(gomock.Any(), "str1", 1).Times(1)
logging.EXPECT().Infof(test.WrapMatcher(gomega.ContainSubstring("some info")), "str1", 1).Times(1)

infof(logging, "some info", "str1", 1)
})
Expand All @@ -114,7 +114,7 @@ var _ = Describe("Logging", func() {
Context("debugf", func() {
When("Debug level is not enabled", func() {
It("should not invoke Debugf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().DebugEnabled().Times(1).Return(false)
logging.EXPECT().Debugf(gomock.Any(), gomock.Any()).Times(0)
Expand All @@ -125,10 +125,10 @@ var _ = Describe("Logging", func() {

When("Debug level is enabled", func() {
It("should invoke Debugf on logger", func() {
logging := mocks.NewMockLogging(mockCtrl)
logging := NewMockLogging(mockCtrl)

logging.EXPECT().DebugEnabled().Times(1).Return(true)
logging.EXPECT().Debugf(gomock.Any(), "str1", 1).Times(1)
logging.EXPECT().Debugf(test.WrapMatcher(gomega.ContainSubstring("some debug")), "str1", 1).Times(1)

debugf(logging, "some debug", "str1", 1)
})
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions neo4j/utils/mocks/factory.go → neo4j/mock_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
* 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
* 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.
* 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 mocks
package neo4j

import "github.com/neo4j-drivers/gobolt"

Expand Down
18 changes: 9 additions & 9 deletions neo4j/utils/mocks/mock_logging.go → neo4j/mock_logging_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions neo4j/utils/mocks/mock_pool.go → neo4j/mock_pool_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dcd86b4

Please sign in to comment.