Giter Club home page Giter Club logo

assistdog's People

Contributors

cezarytarnowski-tomtom avatar rdumont avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

assistdog's Issues

Parsers for pointers

Hi @rdumont,

We're using assistdog here on CashCowPro. Thanks for it =)

We feel the need to add parsers for pointers, so we could handle nullable variables. Right now we're using N/A to identify the nil. So our tables look like this:

Given we have the following products:
    | Title                             | CreatedAt            | UpdatedAt            |
    | Paladone Festive Photo Booth Game | 2017-12-16T00:00:00Z | 2017-12-17T00:00:00Z |
    | N/A                               | 2017-12-18T00:00:00Z | N/A                  |

What do you think about this approach? I would be happy to raise an PR =]

If you want to take a look at our current implementation: https://github.com/cashcowpro/assistdog/pull/1/files

Thanks!

reflect: Elem of invalid type

I've got a gherkin table like the following:

| ID | Name  | Enabled |
| 1  | admin  | true        |

I've created a simple parser (and registered) for boolean. But in the code, when I have the following commands: table, err := assist.CreateSlice(Profile{}, profiles)

I'm getting the error:

reflect: Elem of invalid type
runtime.call64
        /usr/local/go/src/runtime/asm_amd64.s:523
runtime.gopanic
        /usr/local/go/src/runtime/panic.go:513
reflect.(*rtype).Elem
        /usr/local/go/src/reflect/type.go:923
github.com/rdumont/assistdog.(*Assist).createInstance
        github.com/rdumont/assistdog/assist.go:226
github.com/rdumont/assistdog.(*Assist).CreateSlice
        github.com/rdumont/assistdog/assist.go:166

CompareToSlice panics when actual slice has fewer elements than the table

For instance, given the following step definition:

func (s *Steps) ThenTheReturnedErrorsShouldBe(errorsTbl *godog.Table) error {
	actualResponse := []*struct {
		Code        int
		Description string
	}{
		{Code: 123, Description: "Only one error"}, // <-- Only one element here
	}

	if err := assitdog.NewDefault().CompareToSlice(actualResponse, errorsTbl); err != nil {
		return fmt.Errorf("return errors are different from expected: %v", err)
	}

	return nil
}

And the following step in a scenario:

  Then the returned errors should be
    | Code | Description  |
    | 123  | First error  |
    | 456  | Second error |

I would expect to see an error stating that the number of elements is different. However, I got a panic like the following:

panic: reflect: slice index out of range

goroutine 100 [running]:
testing.tRunner.func1.1(0x15b0220, 0x1727ba0)
	/usr/local/Cellar/go/1.15.5/libexec/src/testing/testing.go:1072 +0x30d
testing.tRunner.func1(0xc000316a80)
	/usr/local/Cellar/go/1.15.5/libexec/src/testing/testing.go:1075 +0x41a
panic(0x15b0220, 0x1727ba0)
	/usr/local/Cellar/go/1.15.5/libexec/src/runtime/panic.go:969 +0x1b9
reflect.Value.Index(0x15a4da0, 0xc000153e00, 0x97, 0x1, 0x1a8bfe0, 0x0, 0x0)
	/usr/local/Cellar/go/1.15.5/libexec/src/reflect/value.go:962 +0x1f2
github.com/rdumont/assistdog.(*Assist).CompareToSlice(0xc0003054a0, 0x15a4da0, 0xc000153e00, 0xc00031c7a0, 0x0, 0x0)
	/Users/rodrigodumont/go/pkg/mod/github.com/rdumont/[email protected]/assist.go:212 +0x197

Add strict mode option

When in strict mode, a field that does not exist in the given type will cause an error. Otherwise, it will simply be ignored.

Accept loose field name matching

Variations of case and word spacing should be disregarded when looking for fields. For instance, both First Name, firstname, first Name should match field FirstName.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.