Esempio n. 1
0
func (me *crudExecTest) TestParallelGetColumnMap() {
	t := me.T()

	type item struct {
		id   uint
		name string
	}

	wg := sync.WaitGroup{}

	wg.Add(1)
	go func() {
		i := item{}
		m, err := getColumnMap(i)
		assert.NoError(t, err)
		assert.NotNil(t, m)
		wg.Done()
	}()

	wg.Add(1)
	go func() {
		i := item{}
		m, err := getColumnMap(i)
		assert.NoError(t, err)
		assert.NotNil(t, m)
		wg.Done()
	}()

	wg.Wait()
}
Esempio n. 2
0
func TestSuiteGetters(t *testing.T) {
	suite := new(SuiteTester)
	suite.SetT(t)
	assert.NotNil(t, suite.Assert())
	assert.Equal(t, suite.Assertions, suite.Assert())
	assert.NotNil(t, suite.Require())
	assert.Equal(t, suite.require, suite.Require())
}
Esempio n. 3
0
func (me *adapterTest) TestNewAdapter() {
	t := me.T()
	RegisterAdapter("test", func(ds *Dataset) Adapter {
		return NewDefaultAdapter(ds)
	})
	assert.True(t, HasAdapter("test"))
	adapter := NewAdapter("test", From("test"))
	assert.NotNil(t, adapter)
	removeAdapter("test")

	adapter = NewAdapter("test", From("test"))
	assert.NotNil(t, adapter)
}
Esempio n. 4
0
func Test_Mock_Return_Run(t *testing.T) {

	// make a test impl object
	var mockedService *TestExampleImplementation = new(TestExampleImplementation)

	assert.Equal(t, mockedService.Mock.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Run(func(args Arguments) {
		arg := args.Get(0).(*ExampleType)
		arg.ran = true
	}), &mockedService.Mock)

	// ensure the call was created
	if assert.Equal(t, 1, len(mockedService.Mock.ExpectedCalls)) {
		call := mockedService.Mock.ExpectedCalls[0]

		assert.Equal(t, "TheExampleMethod3", call.Method)
		assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0])
		assert.Equal(t, nil, call.ReturnArguments[0])
		assert.Equal(t, 0, call.Repeatability)
		assert.NotEqual(t, nil, call.WaitFor)
		assert.NotNil(t, call.Run)

	}

	et := ExampleType{}
	assert.Equal(t, false, et.ran)
	mockedService.TheExampleMethod3(&et)
	assert.Equal(t, true, et.ran)

}
Esempio n. 5
0
func (me *databaseTest) TestPrepare() {
	t := me.T()
	mDb, mock, err := sqlmock.New()
	assert.NoError(t, err)
	mock.ExpectPrepare("SELECT * FROM test WHERE id = ?")
	db := New("mock", mDb)
	stmt, err := db.Prepare("SELECT * FROM test WHERE id = ?")
	assert.NoError(t, err)
	assert.NotNil(t, stmt)
}
Esempio n. 6
0
func (me *txDatabaseTest) TestFrom() {
	t := me.T()
	mDb, mock, err := sqlmock.New()
	assert.NoError(t, err)
	mock.ExpectBegin()
	mock.ExpectCommit()
	db := New("mock", mDb)
	tx, err := db.Begin()
	assert.NoError(t, err)
	assert.NotNil(t, tx.From("test"))
	assert.NoError(t, tx.Commit())
}
Esempio n. 7
0
func Test_Mock_TestData(t *testing.T) {

	var mockedService *TestExampleImplementation = new(TestExampleImplementation)

	if assert.NotNil(t, mockedService.TestData()) {

		mockedService.TestData().Set("something", 123)
		assert.Equal(t, 123, mockedService.TestData().Get("something").Data())

	}

}
Esempio n. 8
0
func Test_Mock_findExpectedCall(t *testing.T) {

	m := new(Mock)
	m.On("One", 1).Return("one")
	m.On("Two", 2).Return("two")
	m.On("Two", 3).Return("three")

	f, c := m.findExpectedCall("Two", 3)

	if assert.Equal(t, 2, f) {
		if assert.NotNil(t, c) {
			assert.Equal(t, "Two", c.Method)
			assert.Equal(t, 3, c.Arguments[0])
			assert.Equal(t, "three", c.ReturnArguments[0])
		}
	}

}
Esempio n. 9
0
// NotNil asserts that the specified object is not nil.
//
//    require.NotNil(t, err, "err should be something")
func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) {
	if !assert.NotNil(t, object, msgAndArgs...) {
		t.FailNow()
	}
}
Esempio n. 10
0
func (s *SuiteLoggingTester) TestLoggingFail() {
	s.T().Log("TESTLOGFAIL")
	assert.NotNil(s.T(), nil) // expected to fail
}