mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-22 03:39:08 +02:00
2643321e0f
* Switched to Lab for e2e tests * Switched to binary * Updated lab installation * Updated use of Lab installer * updates * Changed lab installation path * Updated use of installer * Works * Added additional functions * Updated some tests * Updated go.sum * Works * Refactored assertions * Added tests for testing.True * Added tests for testing.None * Added tests for testing.Lte * Added tests for testing.Lt * Added generic consturctor * Added tests for testing.Len * Added tests for testing.Gte * Added tests for testing.Gt * Added tests for testing.False * Added tests for testing.Empty * Added tests for testing.Fail * Added tests for testing.Equal * Added tests for testing.Include * Updated urls in static page tests * Fixed namespace unit tests * Fixed unit test for testing.Len * Updated E2E scripts * Updaes * Updated Chrome in CI/CD * Added e2e for example test click.fql * Added suite cases for example scripts * Updated examples * Updated * Added type assertions * Updated Chrome opts and disabled headers and cookies related tests * Fixed iframes example * Increased timeouts in navigation examples * Updated value example * Updated comments * Disabled cookies examples * Fixed static url * Disabled headers examples * Disabled UA test * Simplified wait logic * Added base testing module * Fixes after codereview * Disabled failing tests
214 lines
6.0 KiB
Go
214 lines
6.0 KiB
Go
package testing_test
|
|
|
|
import (
|
|
"context"
|
|
t "testing"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
"github.com/MontFerret/ferret/pkg/stdlib/testing"
|
|
"github.com/MontFerret/ferret/pkg/stdlib/testing/base"
|
|
)
|
|
|
|
func TestEqual(t *t.T) {
|
|
Equal := base.NewPositiveAssertion(testing.Equal)
|
|
|
|
Convey("When arg is not passed", t, func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := Equal(context.Background())
|
|
|
|
So(err, ShouldBeError)
|
|
|
|
_, err = Equal(context.Background(), values.NewInt(1))
|
|
|
|
So(err, ShouldBeError)
|
|
})
|
|
})
|
|
|
|
Convey("When args are string", t, func() {
|
|
Convey("When 'Foo' and 'Bar'", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := Equal(context.Background(), values.NewString("Foo"), values.NewString("Bar"))
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [string] 'Foo' to be equal to [string] 'Bar'").Error())
|
|
})
|
|
})
|
|
|
|
Convey("When 'Foo' and 'Foo'", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := Equal(context.Background(), values.NewString("Foo"), values.NewString("Foo"))
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are numbers", t, func() {
|
|
Convey("When 1 and 2", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := Equal(context.Background(), values.NewInt(1), values.NewInt(2))
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '1' to be equal to [int] '2'").Error())
|
|
})
|
|
})
|
|
|
|
Convey("When 1 and 1", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := Equal(context.Background(), values.NewInt(1), values.NewInt(1))
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are boolean", t, func() {
|
|
Convey("When False and True", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := Equal(context.Background(), values.False, values.True)
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [boolean] 'false' to be equal to [boolean] 'true'").Error())
|
|
})
|
|
})
|
|
|
|
Convey("When False and False", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := Equal(context.Background(), values.False, values.False)
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are arrays", t, func() {
|
|
Convey("When [1] and [1,2]", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := Equal(
|
|
context.Background(),
|
|
values.NewArrayWith(values.NewInt(1)),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
)
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [array] '[1]' to be equal to [array] '[1,2]'").Error())
|
|
})
|
|
})
|
|
|
|
Convey("When [1,2] and [1,2]", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := Equal(
|
|
context.Background(),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
)
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
func TestNotEqual(t *t.T) {
|
|
NotEqual := base.NewNegativeAssertion(testing.Equal)
|
|
|
|
Convey("When arg is not passed", t, func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := NotEqual(context.Background())
|
|
|
|
So(err, ShouldBeError)
|
|
|
|
_, err = NotEqual(context.Background(), values.NewInt(1))
|
|
|
|
So(err, ShouldBeError)
|
|
})
|
|
})
|
|
|
|
Convey("When args are string", t, func() {
|
|
Convey("When 'Foo' and 'Bar'", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.NewString("Foo"), values.NewString("Bar"))
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
|
|
Convey("When 'Foo' and 'Foo'", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.NewString("Foo"), values.NewString("Foo"))
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [string] 'Foo' not to be equal to [string] 'Foo'").Error())
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are numbers", t, func() {
|
|
Convey("When 1 and 2", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.NewInt(1), values.NewInt(2))
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
|
|
Convey("When 1 and 1", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.NewInt(1), values.NewInt(1))
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [int] '1' not to be equal to [int] '1'").Error())
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are boolean", t, func() {
|
|
Convey("When False and True", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.False, values.True)
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
|
|
Convey("When False and False", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := NotEqual(context.Background(), values.False, values.False)
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [boolean] 'false' not to be equal to [boolean] 'false'").Error())
|
|
})
|
|
})
|
|
})
|
|
|
|
Convey("When args are arrays", t, func() {
|
|
Convey("When [1] and [1,2]", func() {
|
|
Convey("It should return an error", func() {
|
|
_, err := NotEqual(
|
|
context.Background(),
|
|
values.NewArrayWith(values.NewInt(1)),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
)
|
|
|
|
So(err, ShouldBeNil)
|
|
})
|
|
})
|
|
|
|
Convey("When [1,2] and [1,2]", func() {
|
|
Convey("It should not return an error", func() {
|
|
_, err := NotEqual(
|
|
context.Background(),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
values.NewArrayWith(values.NewInt(1), values.NewInt(2)),
|
|
)
|
|
|
|
So(err, ShouldBeError)
|
|
So(err.Error(), ShouldEqual, core.Error(base.ErrAssertion, "expected [array] '[1,2]' not to be equal to [array] '[1,2]'").Error())
|
|
})
|
|
})
|
|
})
|
|
}
|